[Vuejs]-Vuejs2: list of autosize textareas bound to a growing array of objects don't update their value

0👍

nachocab gave me this answer:

Make sure you’re using the key attribute. Otherwise, vue will try to re-use existing dom elements, which may lead to the weird behavior you’re seeing.

=> it works: https://jsfiddle.net/adrienjoly/Lb3yqdso/8/ 🤓

<p v-for="input, i in inputs">
  <autosizing-textarea :key="input.key" :value="input.text"></autosizing-textarea>
</p>

new Vue({
  el: '#demo',
  data: { inputs: [{ key:0 }] },
  methods: {
    add: function() {
      this.inputs.unshift({ key: this.inputs.length });
    },
  },
})

Leave a comment