// 全局前置守卫
router.beforeEach((to, from, next) => {
// 已登录
if (localStorage.getItem('info')) {
next();
}
//登录页,为 ‘/’ ,继续下一页
else if(to.path=='/'){
next(); // 重定向到登录页面
}
//未登录,跳转登录页
else {
next('/'); // 继续
}
});
// 全局前置守卫
router.beforeEach((to, from, next) => {
// 已登录
if (localStorage.getItem('info')) {
next();
}
//登录页,为 ‘/’ ,继续下一页
else if(to.path=='/'){
next(); // 重定向到登录页面
}
//未登录,跳转登录页
else {
next('/'); // 继续
}
});