Before entering each page, you need to judge whether the user has logged in or not.

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()  
  }
Apr.01,2021

did you get it from store.state.isLogin in your first way of writing

?
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ecd0-2bc96.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ecd0-2bc96.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?