Search code examples
vue.jsvuejs2vuexquasar-framework

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)
    },
}

enter image description here


Solution

  • if you have setup Vuex properly, the right way to commit a mutation is

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