Mutation is not set value 无状态 - Vuex

Mutation is not set value no state - Vuex

Mutation is not set value no state.

问题是状态没有被更新。

我做错了什么。

突变

function cardValidationSet (state, data) {
  state.cardValided = data
}

吸气剂

function cardValidationget (state) {
  return state.cardValided
}

组件 A

import Store from '../store'

display: function () {
     Store().commit('disponivel/cardValidationSet', valided)
}

组件 B

import { mapGetters, mapActions, mapMutations } from 'vuex'

computed: {
    ...mapGetters('disponivel', ['cardValidationget'])
  },
methods: {
onSubmitPay () {
      console.log(this.cardValidationget)
    },
}

如果你已经正确设置了 Vuex,提交突变的正确方法是

 this.$store.commit('disponivel/cardValidationSet', valided)