vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.17k stars 923 forks source link

[Bug report] Vue 框架结合 Vue Router 使用时发生的错误 #1334

Closed shaoxiu closed 1 year ago

shaoxiu commented 1 year ago

Description

我接触前段开发的时间不长,难以理解该问题的原因和解决方法。编译发生错误时,我正在尝试在 config.js 为 navbar 添加 children 字段,但看起来并未成功。是我的一些参数设置有问题吗?

Reproduction

https://github.com/HyperCol/MGCD

Used Package Manager

npm

System Info

Run npm run docs:build

> mcgd@1.0.0 docs:build
> vuepress build docs

- Initializing and preparing data
✔ Initializing and preparing data - done in 814ms
- Compiling with vite
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
✔ Compiling with vite - done in 5.68s
- Rendering 36 pages
[Vue warn]: Invalid prop: type check failed for prop "to". Expected String | Object, got Undefined 
[Vue warn]: Unhandled error during execution of render function 
  at <RouterLink class="" to=undefined aria-label="误区纠正"  ... >
✖ Rendering 36 pages - failed in 77ms
TypeError: Cannot use 'in' operator to search for 'path' in undefined
    at Object.resolve (file:///home/runner/work/MGCD/MGCD/node_modules/vue-router/dist/vue-router.mjs:3015:20)
    at ReactiveEffect.fn (file:///home/runner/work/MGCD/MGCD/node_modules/vue-router/dist/vue-router.mjs:2157:41)
    at ReactiveEffect.run (/home/runner/work/MGCD/MGCD/node_modules/@vue/reactivity/dist/reactivity.cjs.js:170:25)
    at get value [as value] (/home/runner/work/MGCD/MGCD/node_modules/@vue/reactivity/dist/reactivity.cjs.js:1142:39)
    at ReactiveEffect.fn (file:///home/runner/work/MGCD/MGCD/node_modules/vue-router/dist/vue-router.mjs:2159:35)
    at ReactiveEffect.run (/home/runner/work/MGCD/MGCD/node_modules/@vue/reactivity/dist/reactivity.cjs.js:170:25)
    at get value [as value] (/home/runner/work/MGCD/MGCD/node_modules/@vue/reactivity/dist/reactivity.cjs.js:1142:39)
    at ReactiveEffect.fn (file:///home/runner/work/MGCD/MGCD/node_modules/vue-router/dist/vue-router.mjs:2184:60)
    at ReactiveEffect.run (/home/runner/work/MGCD/MGCD/node_modules/@vue/reactivity/dist/reactivity.cjs.js:170:25)
    at get value [as value] (/home/runner/work/MGCD/MGCD/node_modules/@vue/reactivity/dist/reactivity.cjs.js:1142:39)
Error: Process completed with exit code 1.