vueRouter.beforeEach(async (to, from, next) => {
if (to.path == '/login') {
let nav = JSON.parse(localStorage.getItem("navMenu"))[0]
console.log("to.path", to.path);
// nav.children?
let napath = nav.children ? nav.children[0].path : nav.path
console.log("napath", napath);
console.log("getisReg", store.state.getisReg);
if (store.state.getisReg) {
next()
} else {
next({
path: napath
})
}
} else {
next()
}
})
vue路由守卫 beforeEach(全局前置守卫)
于 2021-03-12 10:28:07 首次发布