You could add showNote
inside the user_leav
<div v-for="user_leav in user_leave_filtered" v-bind:key="user_leav.id">
<div class="container">
<div v-if="user_leav.note" v-on:click="user_leav.showNote = !user_leav.showNote">
<h4>Note</h4>
</div>
<div class="note" v-if="user_leav.showNote">
<p>{{ user_leav.note }} </p>
</div>
</div>
</div>
Or else you would have to define showNote
as an array
<div v-for="(user_leav, index ) in user_leave_filtered" v-bind:key="user_leav.id">
<div class="container">
<div v-if="user_leav.note" v-on:click="showNote[index] = !showNote[index]">
<h4>Note</h4>
</div>
<div class="note" v-if="showNote[index]">
<p>{{ user_leav.note }} </p>
</div>
</div>
</div>
For the second solution, you will have to make a watcher to "reinitialize" the showNote
array, each time the filters change.
watch: {
user_leave_filitered(newVal) {
// Requires polyfill
this.showNote = new Array(newVal.length).fill(false)
// Or
this.showNote = new Array(newVal.length);
for( note of this.showNote ) {
note = false;
}
}
}
Keep in mind: Array.prototype.fill is not supported in Edge, therefore would need a polyfill.