router.addRoute可以向vue路由中动态的添加路由信息
但路由存在多层级关系
例如
我们最开始的路由是这样的
{
path: '/',
name: 'layout',
component: resolve => require(['../layout'], resolve),
meta: {
title: '',
handleStatus: 2
},
children: [
//用户信息
{
path: '/memberInfo-index',
component: resolve => require(['../views/memberInfo/index'], resolve),
meta: {
title: '欢迎页',
handleStatus: 3,
mainTitle: 1,
memberInfo: true,
permission: false,
isMyFileEnabled: false
}
},
]
}
例如 我们想在 name为layout的这个路由下 加一条子路由 就可以写
import router from "./router";
import theCollaborativeroup from "@/views/workingplatform/the-collaborative-group/index";
router.addRoute(
"layout",
{
path: '/group',
component: theCollaborativeGroup,
meta: {
title: "协同组",
handlestatus: 9,
mainTitle: 2,
permission: false,
isTaskGroupEnabled: false
}
}
)
addRoute的第一个参数接受一个字符串 就是告诉它要插入到那个路由 输入要切入路由的name