[Vuejs]-Button change value of input, but input shows old value

0πŸ‘

βœ…

It is because Vue.js is not picking on changes when you mutate directly in the array.

Instead use Vue.set.

Change your callback:

<button @click="addSeat(index)">Add</button>

And then add this method:

addSeat(index) {
  this.$set(this.nbrSeats, index, this.nbrSeats[index] + 1);
}

Vuejs and Vue.set(), update array

https://v2.vuejs.org/v2/guide/reactivity.html#For-Arrays

Leave a comment