在项目开发过程中,路由用的一个文件 ,每个人都去操作,加上页面挺多了,被版本冲突弄得死去活来得,所以这里下来做了一个路由拆分成各个模块
import Vue from 'vue'
import VueRouter from 'vue-router'
<!====这里引入其他模块得路由>
Vue.use(VueRouter)
const baseRoutes = [
{
path:"/index",
name:"index",
component:App,
meta:{
title:"首页",
keepalive:false//不需要缓存
},
children:[
{
path:"/",
component:Index,
meta:{
title:"首页",
keepalive:false//不需要缓存
}}
]
}
];
const not={
path:"*",
component:NotFound,
}
//login路由单独拿出
const routes=baseRoutes.concat(Login)
//在此处添加属于你模块的路由-----样例:
//routes[0].children.push.apply(routes[0].children,xxx)
routes[0].children.push.apply(routes[0].children,Customer)
routes[0].children.push.apply(routes[0].children, UserManagement)
routes[0].children.push.apply(routes[0].children,Meeting)
routes[0].children.push.apply(routes[0].children, Company)
routes[0].children.push.apply(routes[0].children, Product)
routes[0].children.push.apply(routes[0].children, Attendance)
routes[0].children.push.apply(routes[0].children, Message)
//放在最后
routes[0].children.push(not)
console.log(routes)
export const router= new VueRouter({
routes,
mode:'history',
})
模块路由样例
<!====这里引入你得vue页面>
let routes=[
{ path:"CustomerList",
name:"CustomerList",
component:CustomerList,
meta:{
title:"客户列表",
keepalive:false//不需要缓存
}
},
{ path:"CustomersAdd",
name:"CustomersAdd",
component:CustomersAdd,
meta:{
title:"批量导入",
keepalive:false//不需要缓存
}
},
];
export default routes
这个不一定适合所有,但是可以参考下-,- 我是vue初学者,勿喷-,-