!!!注意:
1.有children时, children对象的path 开头不能加 /
2. 有children时,父级一定要加上component
方法一:addRoute(obj)
const obj = {
path: '/parent',
name: 'home',
component: Home,
children: [
{
path: 'child',
component: () => import('@/views/user/privacy-policy')
}
]
}
this.$router.addRoute(obj)
this.$router.options.routes.push(obj)
方法二:addRoutes(arr)
const obj = {
path: '/yyx123',
component: Layout,
children: [{
path: 'index',
component: () => import('@/views/user/privacy-policy'),
meta: {
title: '认证'
}
}]
}
this.$router.addRoutes([obj])
this.$router.options.routes.push(obj)
|