[Vuejs]-How to get a reference to the specific v-model in form

0๐Ÿ‘

โœ…

Do you have access to n in the function as below?

<div v-for="n in maxLength">
  <input v-model='price.matrix_prices[n]' />
  <div @click="fillPrices(n)">set all to this price
  </div>
  {{n}}
</div>

If yes write the function like this:

methods: {
  fillPrices(n) {
    var data = this.price.matrix_prices[n];
    //do something with the data
  }
}

Leave a comment