简体   繁体   中英

Mutation is not set value no state - Vuex

Mutation is not set value no state.

The problem is that the state is not being updated.

What I'm doing wrong.

Mutation

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

Getters

function cardValidationget (state) {
  return state.cardValided
}

Component A

import Store from '../store'

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

Component B

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

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

在此处输入图片说明

如果您正确设置了Vuex,则提交突变的正确方法是

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM