How does vuex use getters to manage data in state?

do not understand the use of getters token: null token is also valuable in my localStorage
I write as follows: why is token still null in state after refreshing the page? Is this different from the use of computational properties?

getters.js

export default {
  token (state) {
    if (!state.token) {
      let token = JSON.parse(window.localStorage.getItem("token") || null)
      state.token = token
      return token
    }
  }
}
Jun.05,2022

the only way to change the state in the store of the Vuex is to submit the mutation. It is recommended that you take a closer look at the Vuex documentation.


upstairs positive solution, you can take a look at the document, each usage, getter is only as a state return pre-processing, similar to the concept of decorator.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b382db-2c109.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b382db-2c109.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?