I have a question regarding button selection in a v-for loop. I need to allow users to select options from A to C, as shown in the graphic. Additionally, users should be able to press another button like D.
<menu-item
v-for="(item, index) in menu"
:key="`item_${index}`"
@click="setMenuItem(index, item.name)"
/>
In my data property selectedItems
, I store all selected items when the user clicks on setMenuItem()
.
The function works correctly when the user selects just one item, but it does not work when selecting a range of items (e.g., from A to C).
My goal is to push each item.name
into the selectedItems
data property when the user clicks on a range of buttons (e.g., from A to C) by passing the item name as a second argument in setMenuItem()
.
Check out the graphic for reference: graphic