//Please paste the code text below (do not use pictures instead of codes)
It is mainly used for data monitoring and rendering layer. For example, when the token disappears, it will automatically jump to the login page, and when the token is saved, it will automatically jump to the home page. If you operate localstorage directly, you need to monitor events yourself
Specifically, it should be combined with your business scenario. Theoretically, if you save it in localstorage, you don't need to save it in vuex.
The token is stored in vuex, and the page will not be refreshed.
Generally, vuex is used. Localstorage can be used after refresh, and the vuex refresh will be gone. Initialize the variables stored in localstorage to prevent refresh.
I think vuex is stored in memory, and the characteristic of memory is fast. Every time you send a request to the back end to read the token, it will be a little faster... I understand
In fact, all localstorage should be stored in vuex, because the reading of localstorage is a disk reading, and the reading speed is far lower than that of vuex's memory reading. In order to avoid repeated reading of localstorage and affecting the performance, we need to put the data of localstorage into vuex for maintenance. See this article