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
属性
- 删除父级路由的