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
屬性
- 刪除父級路由的