vue根据模块拆分路由

在项目开发过程中,路由用的一个文件 ,每个人都去操作,加上页面挺多了,被版本冲突弄得死去活来得,所以这里下来做了一个路由拆分成各个模块

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初学者,勿喷-,-

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值