vue-router
A page jumps to page B. Page B needs to be logged in. If you are not logged in, you need to jump to the login page, and then jump to page B. Now you can jump to the login page, but after logging in How to implement page b to jump to? Because page b is not a fixed page, it may be an exit page, user center page, etc.
Return to the previous route ?
Wouldn’t it be nice to go back to the previous page?
This needs to be processed on the login page, when jumping to the login page
http://登录页面URL/login?from=${encodeURLComponent(location.href)}
In this way, on the login page, you can get the from parameter in queryString
After the authentication is completed, it will be OK to jump back according to this from
Please refer to the router.beforeEachhook function in the vue-router official documentation, which can be used to implement your functions. The principle is probably:
If you have any questions, please chat privately~