Vue-Router多级路由的默认路由问题
控制台警告信息:
[vue-router] Named Route ‘OverView’ has a default child route. When navigating to this named route (:to="{name: ‘OverView’"), 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.
=>[vue-router] 命名的路由 “OverView “有一个默认的子路由。当导航到这个命名路由(:to=”{name: ‘OverView’”)时,默认的子路由将不会被渲染。从这个路由中删除name属性,并使用默认子路由的名称来代替命名链接。
vue route代码:
{
path: 'overview',
name: "OverView",//删除此属性
component: OverView,
children: [
{
path: 'health',
name: "HealthDevice",
component: HealthDevice
},
{
path: '',
redirect: '/home/overview/health',
}
]
}
问题:
我们为一级路由设置了默认的子路由,实际是访问了设置的子路由,所以把一级路由的name属性去掉即可。
处理方法:
将父级路由的name属性删除