目录
Routes 选项参数
{
path: '/foo',
name: '/foo',
component: Foo ,
redirect: '/sign' ,
meta: {} ,
children: [] ,
}
flatten.js 动态组装
const flatten=(options=[]){
const routes=[]
// options 组装
options.forEach((item)=>{
const route = {
path: item.path,
component: item.layout || HeaderAsideLayout,
children: [
{
path: '',
name: item.name,
component: item.component,
redirect: item.redirect,
meta: item.meta
}
]
}
// 递归
if (Array.isArray(item.children)) {
flatten(item.children)