B
B
bqio2018-10-24 09:28:12
Vue.js
bqio, 2018-10-24 09:28:12

How to output an array of inputs in a Vue loop and bind them dynamically to this array?

There is a code:

<div v-for="(item, index) in content" :key="index">
  <input type="text" v-model="content[index]"  class="u-full-width">
</div>

watch: {
    content () {
      console.log(this.content)
    }

It is necessary that after changing the text in any of the inputs from that array, the function in watch is triggered and the array values ​​are updated. But v-model="content[index]" throws an error. How would it be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2018-10-24
@bqio

https://en.vuejs.org/v2/api/index.html#watch
Look at the deep option .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question