I have been attempting to implement a change event in my Vue application, where a statement switches between true and false each time I check a checkbox. However, the functionality doesn't seem to be working as expected.
This issue arose while following along with a tutorial that inspired me to experiment by adding this change event.
<div v-for="task in tasks" :key="task.id" v-if="task.completed">
<ul>
<li v-text="task.description"></li>
<input type="checkbox" @change="changeComplete">
</ul>
</div>
var app = new Vue ({
el: '#root',
data: {
tasks: [
{description: 'clean room', completed: true, id: 1},
{description: 'do homework', completed: true, id: 2},
{description: 'go to sleep', completed: false, id: 3}
]
},
methods: {
changeComplete() {
this.task.completed = !this.task.completed;
}
}
})
Despite expecting the completion status of a task to toggle when its checkbox is checked, the change event fails to trigger, leaving the completed value unaltered.