[Vuejs]-How to properly use dinamic id name in vue v-for?

0👍

From what I understand you want something like this:

<div v-bind:id="'singoloGialla-' + index" class="row">
  <p>{{servizio.descrizione}}</p>
</div>

and

< ... v-bind:data-target="'#singoloGialla-' + index">

So, we are taking the string 'singoloGialla-' and concatenating it with the the dynamic value of the index variable. When we use the + operator to concatenate a string and a number, the number is first converted to a string, then concatenated to the existing string. This is not Vue specific, but normal JavaScript behavior.

Leave a comment