api:/zh/guide/
Scene:
When logging in, the user information obtained by logging in is stored in the state and sessionStorage of vuex. When using it, get it in the state. When there is no data in the state due to refresh or other reasons, go to the sissionStorage to get it.
mistake:
After logging in, when you need to obtain user information, the method of the property in getters will not be executed. Just go to getters to get cache
Solution:
Rewrite the properties in getters into methods, so that they will be executed every time they are called to re-get data.
getloginInfor: (state) => () => {}
Code:
import Vue from 'vue' import Vuex from 'vuex' (Vuex) export default new ({ state: { /* Login user information */ loginInfor: { } }, mutations: { setloginInfor (state, msg) { = msg } }, actions: { }, getters: { getloginInfor: (state) => () => { // Get user login information from state first let loginInfo = // If you cannot get it in state, then get it from localStorage if (!loginInfo) { loginInfo = (('loginInfo')) } return loginInfo } } })
use:
this.$()
The above article solves the problem of not executing $ calls is all the content I have shared with you. I hope you can give you a reference and I hope you can support me more.