In Vuejs3, I'm looping over an array of objects :
<div 
   v-for="ligne in lignes" 
   :key="ligne.id" 
   :class="{ 'border-b-2':isSelected }" 
   :id="`ligne_${ligne.id}`"
 >
     <span @click="select(ligne.id)">X</span>
</div>
I want to add the class 'border-b-2' only to the line selected line, but I don't see how to do that dynamically. When I now set isSelected to true in the vue devtools, all lines get that style applied.
As a workaround, what I now do is wrapping this code in a function (select(id)) and change the html class
document.getElementById(`ligne_${id}`).classList.add('border-b-2')
That seems verbose. How to do this, leveraging on the :key or the v-for loop?


selectsupposed to be toggling the state of the div?