共计 564 个字符,预计需要花费 2 分钟才能阅读完成。
router.beforeEach
router.beforeEach((to: any, from: any, next: any) => {// console.log(to.path)
// const token = to.query.token || ''// if (token !=='') {// localStorage.setItem('DingToken', token)
// }
const {permissions} = store.state
console.log('permissions',permissions)
if (permissions.length > 0) {const { meta} = to
const index = permissions.findIndex((item: any) => {return item === meta.permissionsCode})
if (meta.permissionsCode && index !== -1) {next()
return
} else if (to.path !== '/default') {if (meta.noVerify) {next()
} else {Message.error('无权限!')
next('/')
}
} else if (to.path === '/default') {next()
}
} else {next()
}
return
})
正文完