main.js Code:
//
router.beforeEach((to, from, next) => {
let myCookie = global.getCookie("token");
if (!myCookie && to.path != "/login"){
router.push("/login");
}
else{
next();
}
});
No matter which page you click, as long as you are not logged in, you will jump to the login page. This is no problem
then changed the requirements, so you can see it even if you don"t log in on the home page, so I change it like this
//
router.beforeEach((to, from, next) => {
let myCookie = global.getCookie("token");
if (!myCookie && to.path != "/"){
router.push("/login");
}
else{
next();
}
});
as a result, the browser reported an error. What is the reason for this?