0👍
const selected = ref('ALL')
const filteredList = computed(() => {
return shows.value.filter((el) => selected.value === 'ALL' || el.category.includes(selected.value))
})
whenever you press the button, you only need to change selected
ref.
filteredList
computed will be executed whenever selected
changes.
add this method in script setup.
const onClickChoice = (val) => {
selected.value = val
}
and add @click like this.
<div class="choice-list">
<div
class="choice"
v-for="(choice, index) in labels[activeIndex].choice"
:key="index"
@click="onClickChoice(choice)"
>
{{ choice }}
</div>
</div>
Source:stackexchange.com