我知道我们可以使用$router.push({ name: 'route-name' }).
我想知道的是如何使用child route name. 这是我的路线结构:
export default [
{
path: '/',
name: 'home',
component: () => import('@/views/Home.vue'),
childs: [
{
name: 'home.about',
path: '/about',
component: import('@/views/Home/About.vue')
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
但我的控制台说[vue-router] Route with name 'home.about' does not existfor $router.push({ name: 'home.about' }).
我缺少什么?
Obs:这个想法是不要使用 hard 路由到孩子route path。
你有一个错字。
应该是children又不是childs。
export default [
{
path: '/',
name: 'home',
component: () => import('@/views/Home.vue'),
children: [
{
name: 'home.about',
path: '/about',
component: import('@/views/Home/About.vue')
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1787 次 |
| 最近记录: |