[Vuejs]-How to get the updated value when saving in vue

0👍

There is two issues with your code:

  1. v-model should be used with data only and not with computed. a computed property value in Vue.js can not be changed unless the value or one of the values it depends on has changed.

  2. You can not update the state directly. This is one of vuex rules. To update it you have to use a vuex mutation for that.

So the solution is:

  1. Create a data property called tempPageLimit and bind it to the input using v-model.

  2. In the store, Create a mutation that update the pageLimit with the value of the tempPageLimit and map it to your component using mapMutations.

  3. Execute this mutation inside the onSave method.

look here if you want to read about vuex mutations.

Leave a comment