[Vuejs]-How to get info stored in the state of the store.js in vue?

3๐Ÿ‘

โœ…

Actions are similar to mutations, the differences being that: Instead of mutating the state, actions commit mutations.

You need to commit a mutation instead of directly altering state:

  state: {
    ...
    fisrtStepInfo: {}
  },
  mutations: {
    setStepInfo: (state, data) => state.fisrtStepInfo = data;
  }
  actions: {
    formInfo({commit, dispatch}, authData) {
      console.log(authData)
      commit('setStepInfo', authData)
      console.log(this.fisrtStepInfo)
    }
  },
  getters: {
    formInfoFirstStep (state) {
      console.log(state)
      return state.fisrtStepInfo
    }
  }
๐Ÿ‘คDaniel_Knights

Leave a comment