Vue提示warn[vue-router] Named Route ‘home’ has a default child route…
Posted JackieDYH
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Vue提示warn[vue-router] Named Route ‘home’ has a default child route…相关的知识,希望对你有一定的参考价值。
问题复现
Vue的项目中使用了Vue-Router,当某个路由有子级路由时
export default new Router({
routes: [
{
path: '/',
name: 'home',
component: Home,
children:[
{
path:'conl',
name: 'console',
component: Console,
}
]
}
]
})
报出如下警告
[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.
解决
当某个路由有子级路由的时候,这时候父级路由需要一个默认的路由,所以父级路由不能定义
name
属性,解决办法是:即去除父级的
name
属性即可
以上是关于Vue提示warn[vue-router] Named Route ‘home’ has a default child route…的主要内容,如果未能解决你的问题,请参考以下文章
vue router提示 [vue-router] Named Route ‘layout‘ has a default child route.
uni-app的Vue项目中Echarts的报错提示:[Vue warn]: Error in data(): “ReferenceError: echarts is not defined“
vue2.XX 提示[Vue warn]: Error in render: "TypeError: Cannot read property 'img' of undef