Can somebody please tell me how I have to write the "doneChange" method that I can access on the individual index of the tasks list to change the boolean of finish from true to false and viceversa?
My Code:
<template>
<div>
<h1>Alle Aufgaben</h1>
<ul>
<li v-for="(task, index) in tasks" :class="{ 'done' : task.finish}">
<p>{{task.description}}</p>
<button class="doneChange" @click="doneChange(index)">✓</button>
<button class="del" @click="del(index)">X</button>
</li>
</ul>
</div>
</template>
<script>
import { ref, reactive, computed } from "vue";
export default {
setup() {
let tasks = [
{description: "Frühstücken", finish: true},
{description: "Lernen", finish: false},
{description: "Trainieren", finish: false},
{description: "Einkaufen", finish: false},
{description: "Mails", finish: false},
{description: "Abendessen", finish: false},
];
const del = (index) => this.tasks.splice(index,1);
const doneChange = (index) => tasks(index).finish = !tasks(index).finish;
return { tasks, del, doneChange };
}
};
</script>
With this I get the error:
Uncaught TypeError: tasks is not a function