在路由的meta里设置
access: ['1'] //一个权限
access: ['1', '2', , '3', '4'] //多个权限
在vuex里设置
state: {
access: '',
},
mutations: {
setAccess (state, accesses) {
let access = [];
access.push(accesses)
state.access = access;
}
}
在路由守卫里限制在地址栏输入能够跳转的问题
router.beforeEach(async (to, from, next) => {
iView.LoadingBar.start()
//解决从路由输入能够跳转的问题
if (canTurnTo(to.name, store.state.user.access, routes)) {
next()
} else {
router.push({path: '/401'})
}
})
到这里就是大功告成啦