我们先来分析一下后台的页面结构,后台页面大部分都基于一个layout模版,在模版中有导航,面包屑信息,用户信息等,我们可以看作内容页面都是模版的子路由,
除了基于模版的页面外,登录页面,404,403页面都不基于模版,可以看作和layout平级的一级页面,具体内容页,则是layout的子路由,属于二级页面
路由结构
我们的路由结构应该类型这样的
routes: [ { path: '/site/login', name: 'login', component: Login, meta:{requiresAuth:false}, }, { path: '/404', name: '404', component:NoFind, meta:{requiresAuth:false}, }, { path: '/403', name: '403', component:Forbidden, meta:{requiresAuth:false}, }, { path: '/index', name: 'dashboard', component: (resolve) => require(['@/pages/layout/Layout'], resolve), meta:{requiresAuth:true,noPermission:true}, children:[ { path: '/site/update-pwd', name: 'site-update-pwd', component: (resolve) => require(['@/pages/site/UpdatePwd'], resolve), meta:{requiresAuth:false,noPermission:true}, }, { path: '/administrators/index', name: 'administrators-index', component: (resolve) => require(['@/pages/permission/AdministratorsIndex'], resolve), meta:{requiresAuth:true}, }, ....... ] }, ]