Where is the value of store.state for Vuex?

We know that the state value of vuex will be emptied when the browser is refreshed. I thought that the value could be stored in the local database, so what should vuex"s state do to get the corresponding value from cookie or other localized places when refreshing the browser?

Mar.12,2021

haven't you saved it in the local database? before initializing state, you should first check whether there is a value in the local database. If so, initialize the database value for state. Do you think this is the case? If you save
, you can directly take out the value of state, serialize it into a string, store it in localStorage, initialize and read the string from localStorage when refreshing and open, and deserialize it to object initialization to state


const store = new Vuex.Store({
  // 
  state: {
    headImg: JSON.parse(sessionStorage.getItem('headImg')) || ""
  },
  mutations: {
    newImg(state, msg){
      sessionStorage.setItem('headImg', JSON.stringify(msg))
      state.headImg = msg;
    }
  }
})
.
Menu