vue , 进入页面判断是否有权限,无权限进入登录
1.router.js{path: '/deliver', //发货component: (resolve) => require(['../components/pages/deliver'], resolve),meta: {requiresAuth:true,keepAlive: true,}...
·
1.router.js
{
path: '/deliver', //发货
component: (resolve) => require(['../components/pages/deliver'], resolve),
meta: {
requiresAuth:true,
keepAlive: true,
}
},
2.main.js
router.beforeEach((to, from, next) => {
if (to.meta.requiresAuth && !localStorage.getItem('uid')) {
next({path: '/login'})
} else {
next()
}
})
更多推荐
已为社区贡献9条内容
所有评论(0)