[Vuejs]-Vue3 / Vuex changing store state doesn't update computed prop

0👍

change your store like this:

const store = new Vuex.Store({ // this line changed ...
  state: {
      numItems: {{ cart.get_cart_length }}
  },
  mutations: {
      increment(state, quantity) {
          console.log(quantity)
          state.numItems += quantity
      }
  }
});  // and this line changed ...

and for call your mutation you can use store without this keyword (like your computed property)

store.commit('increment', 1)

or with this keyword:

this.$store.commit('increment', 1)

Leave a comment