Answer the question
In order to leave comments, you need to log in
Why doesn't it handle array reactivity in vue?
Good afternoon.
Application on nuxt, there is an array (items I get through props):
<template>
<tr v-for="item in items" :key="item._id" @click="select(item)">
<td>
<input type="checkbox" v-model="item.checked">
</td>
<!--...-->
</tr>
</template>
<script>
methods: {
select1: function(item) {
item.checked = !item.checked
},
select2: function(item) {
this.$set(item, "checked", !item.checked)
},
select3: function(item) {
this.$set(item, "checked", !item.checked)
this.$set(this.items, item._id, item)
},
// еще был вариант с индексом, но не стал приводить
}
</script>
Answer the question
In order to leave comments, you need to log in
Found. The problem was that originally "checked" was NOT added reactively. :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question