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属性)
标签:将子,vue,false,resolve,addRoute,router,路由,layout From: https://www.cnblogs.com/pwindy/p/17610310.html