How does the routing guard of vue-router jump to route?

I want to use vue-router "s navigation guard to define a global guard to listen for changes in routing
to implement a function that intercepts entry to the page, and then jumps to the login page
but what I write is always wrong. I can"t find a solution after Google. Please tell me how to do
error message:

clipboard.png

:

clipboard.png

ask for help, thank you very much!


clipboard.png


next({ path: '/login', replace: true })

should be possible


there is an endless loop. BeforeEach means that accessing all routes will execute next ('/ login'), visit / login execute next ('/ login') and then visit / login execute next ('/ login') and access / login execute next ('/ login'). It can be judged that next ('/ login')


endless loop can be executed when from.name is not login.
next ('/ login') can be understood as redirecting to / login.
so you will also enter the hook function, and when you judge again, you will also enter the if branch.

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-1bede62-31337.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-1bede62-31337.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?