0

我需要将数据从 getter 传递到 vuex 4 中的操作,但我不知道我是否做得对。我应该怎么做呢?应该注意的是,getter 正在从位于不同模块中的另一个 getter 中获取状态数据。

module: localStorage.js

<script>
export default{
  namespaced: true,

  state:{


  },

  mutations:{

    TOMAR_SERIE(getters){

      if (localStorage.getItem('lasSeries')){
        let lasSeries = JSON.parse(localStorage.getItem('lasSeries'))
        lasSeries.forEach(serie => {
          getters.getStateDef.value.push(serie)
          console.log('llega getters?')
        });
      }
    }
  },

  actions:{

      async getCartItems({ commit, getters, rootState, rootGetters }) { //How should I express this so that the action takes the data from the getter?

        rootGetters.getStateDef
        commit('TOMAR_SERIE')
      }
},

  getters:{

    getStateDef: (state, getters, rootState, rootGetters) =>{  //get state from another module
      return rootGetters['lista/getState']
    }
    
  },

}
</script>

4

0 回答 0