dewfall123 / vitepress-for-component

📖 针对组件开发的VitePress。 重构版本https://github.com/dewfall123/ruabick
https://dewfall123.github.io/vitepress-for-component/
MIT License
194 stars 38 forks source link

vite添加enhanceApp 报错 #38

Closed GlenHeart closed 3 years ago

GlenHeart commented 3 years ago

Describe the bug .vitepress/theme/index.js 添加enhanceApp 报错

To Reproduce Steps to reproduce the behavior: .vitepress/theme/index.js 创建文件 添加代码如下: image

Expected behavior A clear and concise description of what you expected to happen. 期望是正常的,但是页面是报错了,runtime-core.esm-bundler.js:6568 [Vue warn]: Invalid vnode type when creating vnode: undefined. at System Info

Additional context Add any other context about the problem here.

GlenHeart commented 3 years ago

其实我就是想在页面加个element-ui

GlenHeart commented 3 years ago

const VitePressApp = { name: 'VitePressApp', setup() { if (import.meta.env.PROD) { // in prod mode, enable intersectionObserver based pre-fetch usePrefetch(); } return () => h(Theme.Layout); } }; 感觉这里可以加个提示

GlenHeart commented 3 years ago

importMap: { ElementPlus: 'https://cdn.jsdelivr.net/npm/element-plus@1.1.0-beta.20/dist/index.full.min.js', } 使用这种方式报props类型需要个string

GlenHeart commented 3 years ago

runtime-core.esm-bundler.js:6568 [Vue warn]: Invalid prop: type check failed for prop "importMap". Expected Object, got String with value "%7B%22ElementPlus%22%3A%22https%3A%2F%2Fcdn.jsdelivr.net%2Fnpm%2Felement-plus%401.1.0-beta.20%2Fdist%2Findex.full.min.js%22%7D". at <Demo src="./demo/demo.vue" language="vue" title="基本用法" ... > at at at at at

dewfall123 commented 3 years ago
  1. enhanceApp 报错是要这样写 可以参考文档 https://vitepress.vuejs.org/guide/theming.html#extending-the-default-theme
    
    // theme/index.js
    import DefaultTheme from 'vitepress-for-component/dist/client/theme-default';

export default { ...DefaultTheme,

enhanceApp({ app, router, siteData }) { // app is the Vue 3 app instance from createApp(). router is VitePress' // custom router. siteData`` is aref`` of current site-level metadata. }, };


2.   提示“props类型需要个string” 这个是bug,我处理下

3.   其实可以直接`import {x} from 'element-plus'` 使用吧,不用在主题引入?