[Vuejs]-Update checkbox at click event vue.js

0πŸ‘

<td v-for="(test, index) in tests" :key="index">
  <div class="checkbox">
    <input type="checkbox" v-model="test.checked" @click="update(test.checked)">
  </div>
</td>

Adding the key to the for loop should fix this, because vue v-for loops are a bit tricky. They can’t really detect any change in objects. However it should detect, that the indexes change and rerender accordingly.

0πŸ‘

try with below answer:

<td v-for="test in tests">
  <div class="checkbox">
    <input type="checkbox" v-model="test.checked" @click="update(!test.checked)">
  </div>
</td>

Leave a comment