javascript - vue2.0 realizes that after logging in, all pages do not need to be logged in, and no login is required. The address of any page visited is transferred to the login page. How to achieve this?
大家讲道理
2017-05-19 10:36:19
vue After logging in, all pages do not need to be logged in, and no login is required. The address of any page accessed is transferred to the login page to implement the idea.
The project uses vue2.0 axios,
Keywords:
Token-based authentication, JWT, axios interceptor
Link:
Reference link
In the routing configuration, add the route that requires login
Determine whether the user is logged in in main.js, and jump to the login page if not logged in
Save the login status in local storage or cookie or vuex (preferably vuex), and then the rest is similar to the above