Vuex uses mapActions to report Cannot read property 'dispatch' of undefined

mapActions using vuex

//storeaction
const actions = {
  setLoginInfo ({ commit }, data) {
    localStorage.setItem("loginStatus", true)
    commit("SET_LOGIN_STATUS", true)
  },

  setGwShopUserToken ({ commit }, token) {
    localStorage.setItem("GwShopUserToken", token)
    commit("SET_GW_SHOP_USER_TOKEN", "")
  },
}

//
  ...mapActions([
      "setGwShopUserToken"
    ])

I don"t know what caused it

Aug.31,2021
Can the

subject provide multiple codes?


do you use mapActions in methods? See if you set the mapActions where the this points to not the virtual dom.

Menu