vue3-core/playground/src/todo-mvc.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
968 B
Vue
Raw Normal View History

<script setup lang="ts">
2024-01-21 02:16:30 +08:00
import { ref } from 'vue/vapor'
interface Task {
title: string
completed: boolean
}
const tasks = ref<Task[]>([])
2024-01-20 13:38:20 +08:00
const value = ref('hello')
function handleAdd() {
tasks.value.push({
title: value.value,
completed: false,
})
// TODO: clear input
value.value = ''
}
</script>
2024-01-20 13:38:20 +08:00
<template>
<ul>
<!-- TODO: v-for -->
<li>
<!-- TODO checked=false -->
<input type="checkbox" :checked="tasks[0]?.completed" />
{{ tasks[0]?.title }}
</li>
<li>
<input type="checkbox" :checked="tasks[1]?.completed" />
{{ tasks[1]?.title }}
</li>
<li>
<input type="checkbox" :checked="tasks[2]?.completed" />
{{ tasks[2]?.title }}
</li>
<li>
<input type="checkbox" :checked="tasks[3]?.completed" />
{{ tasks[3]?.title }}
</li>
<li>
2024-01-21 02:16:30 +08:00
<input type="text" v-model="value" />
2024-01-20 13:38:20 +08:00
<button @click="handleAdd">Add</button>
</li>
</ul>
</template>