Vue 路由导航守卫
router.beforeEach((to, from, next) => {
let userInfo = localStorage.getItem('userInfo');
let leftList = JSON.parse(window.localStorage.getItem("Menu"))
if (userInfo && to.path == '/login') {
next({
path: '/',
replace: true
})
} else if (!userInfo && to.path != '/login' ) {
next({
path: '/login',
replace: true
})
} else {
next()
}
})```