很多小伙伴直接在路由文件中写路由,这样会导致路由文件往往有几千行,整个文件会很繁琐。我们可以新建一个路由文件夹,importexportdefault{path:'/index',name:'index',component:()=>import('../view/index.vue'),children:[//sub-routes]}然后importconstrouterList=[];functionimportAll(route){route.keys().forEach((key)=>routerList.push(route(key).default));}importAll(require.context('./',true,/\.routes\.js/));constroutes=[{path:name:conmponent:},...routerList,]
