router.addRouter的基础用法
静态路由
const routes = [
{
path: '/',
name: 'Login',
component: () => import(/* webpackChunkName: "about" */ '@/views/Login.vue')
},
{
path: '/index',
name: 'index',
meta: { title: '首页', noCache: true },
component: () => import(/* webpackChunkName: "about" */ '@/views/index.vue'),
children:[]
// children: [{
// path: '/test',
// name: 'test',
// component: () => import('../views/test.vue')
// }
// ]
}
]
动态路由
const routeObj = {
path: 'index/test', // 这里要把父路由的路径也带上
name: 'test',
meta: { title: '测试路由test', noCache: true },
component: () =>
import('../test/test.vue'),
}
//添加子路由只需把addRoute第一个参数填写父级路由的name
this.$router.addRoute('index', routeObj)
标签:index,Vue,name,--,component,test,import,路由
From: https://www.cnblogs.com/zhouwying/p/16837255.html