Reputation: 81
I have a plain array of strings in my data and I would like to enable their editing/adding with
<ul>
<li v-for="(string, index) in strings" :key="index">
<input v-model="string">
</li>
</ul>
the problem is that the strings in the array are not changed when the user types in the input.
Here is a Jsfiddle https://jsfiddle.net/franta/74ybd0g5/10/ I would like the "Strings" part to work like the "Things".
Thanks
Upvotes: 0
Views: 700
Reputation: 8368
Try this: v-model="strings[index]"
By doing this you are passing by reference and not by value. Meaning, instead of having two separate instances between strings
and your v-model="string"
they both share the same instance instead.
Upvotes: 1