Reputation: 75
I have a array with objects:
array = [{id: 1, value: 0},{id: 2, value: 0},{id: 3, value: 0},{id: 4, value: 0}]
after a quick selection with my UI I have a selected object array
selectedArray = [{id: 1, value: 0},{id: 2, value: 0},{id: 1, value: 0}]
You can not I push 2 time the id:1, it's necessary for my timeline.
so now I make a v-for on it
<div v-for="item in selectedArray">
<input type="number" v-model="item.value">
</div>
But If I change the value of the first item , the third change too.
How can I fix this
Upvotes: 0
Views: 30
Reputation: 121
You can add key attribute to each item.
<div v-for="(item, index) in selectedArray" :key="index">
<input type="number" v-model="item.value">
</div>
Upvotes: 1