the two writing methods written in vue-router "s beforeEach (pictured)
above the entire page is not displayed;
the following writing is normal, but the following writing is vue-router settings requireLogin, does not write some custom operations!
if(store.state.isLogin==false){
next("/login")
}else{
next()
}
if(to.matched.some(res => res.meta.requireLogin)){ //
next("/login")
}else{
next()
}
well, it will take 40 minutes to solve it. Just now the page can"t be opened. The console has been in a loop. I don"t know what"s wrong with it. I just saw a blog where the login page is in an endless loop, so the code can be changed to this
. if(store.state.isLogin==false){
if (to.name === "login") {
next();
return
}
next("/login")
}else{
next()
}