当前位置:   article > 正文

[vue-router] “path“ is required in a route configuration报错_[vue-router] "path" is required in a route configu

[vue-router] "path" is required in a route configuration.

原因

在router.js文件里配置路由时,不能写空{},在程序里写了空{}是不会报错的,但在程序运行时扫描{}中没有path时会报错

解决方法

删除{}或者在{}里补全配置至少又要path,和component

正确例子

  1. routes: [
  2. {
  3. path: '/',
  4. name: 'home',
  5. component: Home,
  6. redirect: '/index',
  7. children: [
  8. {
  9. path: '/index',
  10. name: 'index',
  11. component: Index,
  12. }
  13. ]
  14. }
  15. ]
  16. });

错误例子

  1. routes: [
  2. {
  3. path: '/',
  4. name: 'home',
  5. component: Home,
  6. redirect: '/index',
  7. children: [
  8. {
  9. path: '/index',
  10. name: 'index',
  11. component: Index,
  12. }
  13. ]
  14. },
  15. { 报错 }
  16. ]
  17. });

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/224652
推荐阅读
相关标签
  

闽ICP备14008679号