I am facing an issue with my checkboxes that are generated dynamically in a component using a v-for
loop. Once a checkbox is checked, it is added to an array of selected checkboxes. The problem arises when a checked checkbox is removed - the v-model
still includes the removed checkbox. How can I update the v-model
to reflect changes in the array? I have already tried re-rendering the entire component, but that is not the ideal solution.
<div v-for="player in players" :key="player.id">
<input
v-model="selectedPlayers"
:value="player.id"
type="checkbox"
:id="player.id"
/>
<label :for="player.id">
{{ player.name }}
</label>
</div>
Current Issue
https://i.sstatic.net/YDr0E.png
Desired Solution