vue-router权限控制
路由元信息(meta)+全局导航守卫
router.beforeEach((to,from,next)=>{
if(to.meta.roles.includes(role)){
next() //放行
}esle{
next({path:"/404"}) //跳到404页面
}
})动态添加路由控制
填坑
// 定义一个函数来创建router
export const createRouter = routes => new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
});
router.match = createRouter(constantRoutes).match;最后更新于