第一步
在路由的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'})
}
})
到这里就是大功告成啦
转载请注明原文地址:https://ipadbbs.8miu.com/read-6330.html