突变未设置为无状态。
问题是状态没有被更新。
我做错了。
突变
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)
},
}
答案 0 :(得分:1)
如果您已正确设置Vuex,则提交突变的正确方法是
this.$store.commit('disponivel/cardValidationSet', valided)