[vue-router] Named Route 'Home' has a default child route.


vue-router.esm.js?fe87:16 [vue-router] Named Route 'Home' has a default child route. When navigating to this named route (:to="{name: 'Home'"), the default child route will not be rendered. Remove the name from this route and use the name of the default child route for named links instead.

routes: [
    {
      path: '/',
      name: 'Home', // 删除后正常
      component: Home,
      children: [
        {
          path: '/topiclist/:tab',
          component: TopicContent
        },
        {
          path: '',
          redirect: '/topiclist/all'
        }
      ]
    },
}
  • 问题描述

    • 在给路由设置子路由
    • 以及子路由设置默认路由
    • 然后运行抛出上图错误(页面正常渲染)
  • 问题原因

    • 在设置好子路由,以及子路由的默认路由后,此时子路由是一个路由集
    • 而某个路由有子集路由的时候,该路由需要一个默认的路由且不能定义name属性。
  • 解决方法

    • 删除父级路由的name属性


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM