While looping through a list and using a @click function to update other elements, I have encountered an issue with the index values bound to selectedFixtures
. Each time I click on an element, it initially prints out []
, and then on subsequent clicks, it displays the old value like [1]
. How can I ensure that my function works with the current values so that it outputs [1]
on the first click?
<v-chip-group
v-model="selectedFixtures"
multiple
>
<v-chip v-for="(f, i) in filteredFixtures()" :key="i" @click="selectFixture(f, i)">
<div class="d-flex align-baseline">
<span class="font-weight-medium">{{ f.name }}</span>
</div>
</v-chip>
</v-chip-group>
methods: {
selectFixture(f, index) {
console.log(JSON.stringify(this.selectedFixtures));
if (this.selectedFixtures.length === 1) {
console.log('here!')
}
}
}