I can’t seem to figure out how to toggle a class on a specific item in a table. I’m using v-for to loop over the data and printing it out to the user. The goal is to toggle a class when the user clicks on a specific element inside the table. When i’m trying to add a v-bind:class="{'active' : isActive} it just adds that class to all of them and not the specific.
<table>
<tbody>
<tr v-for="(item, index) in tableFilter" @click="selectThis(item)" v-bind:class="{'active': isActive}">
<td>{{item.Name}}</td>
<td>{{item.Address}}</td>
<td>{{item.Telephone}}</td>
<td>{{item.Email}}</td>
</tr>
</tbody>
</table>
export default {
data() {
return {
isActive: false,
data: data
}
},
methods: {
selectThis(val, index) {
this.isActive =! this.isActive
}
},
computed: {
tableFilter() {
return data;
}
}