vitepress
vitepress copied to clipboard
Build error: ReferenceError: document is not defined
Is your feature request related to a problem? Please describe.
Whenever I execute pnpm docs:build, I always fail to package successfully and get an error ReferenceError: document is not defined.
Describe the solution you'd like
docs system is built successfully! No error is reported when executing pnpm docs:build. And a successful dist package is packaged.
Describe alternatives you've considered
No response
Additional context
github : https://github.com/Hollelihanqi/qh-ui.git /** @type {import('vitepress').Theme} */
import { h } from "vue"; import VPApp, { NotFound, globals } from "../vitepress"; import DefaultTheme from "vitepress/theme"; // import { define } from '../utils/types'
// import 'uno.css' import "virtual:uno.css"; import './style.css'
import "../vitepress/styles/base.scss";
import ElementPlus from "element-plus"; import "element-plus/dist/index.css"; import YtoUplus from '@yto/custom' import '@yto/custom/index.css'
// import type { Theme } from 'vitepress' export default { extends: DefaultTheme, NotFound, Layout: VPApp, async enhanceApp({ app }) { globals.forEach(([name, Comp]) => { app.component(name, Comp); }); app.use(ElementPlus); app.use(YtoUplus); // @ts-ignore // if (!import.meta.env.SSR) { // const custom = await import('@yto/custom').then((m) => m) // app.use(custom.default) // } }, // Layout() { // return h(DefaultTheme.Layout, null, { // "aside-outline-before": () => h("div", {}, "我是前置内容"), // }); // }, };
Validations
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Read the Contributing Guidelines.
- [X] Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.
Please share a minimal example using https://vitepress.new and read the docs for possible solutions - https://vitepress.dev/guide/ssr-compat
解决了么,我也遇到同样的问题
解决了么,我也遇到同样的问题
我遇到了同样的问题,我解决了,大概情况是需要在onMounted中访问document、window这些浏览器API