From 435cefc3dfad72adba51acb7104cea7f88389350 Mon Sep 17 00:00:00 2001 From: roger Date: Thu, 19 Jan 2023 18:16:14 +0800 Subject: [PATCH] =?UTF-8?q?todolist=E5=AD=A6=E4=B9=A0=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E4=BB=A3=E7=A0=812-=E7=BC=96=E5=86=99=E9=83=A8=E5=88=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BD=86=E6=98=AF=E9=81=87=E5=88=B0=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20Error=20in=20v-on=20handler:=20"TypeError:=20this.c?= =?UTF-8?q?heckTodo=20is=20not=20a=20function"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 20_脚手架/vue_code/src/App.vue | 31 +++++++++++++++++-- .../vue_code/src/components/TodoHeader.vue | 21 +++++++++++-- .../vue_code/src/components/TodoItem.vue | 16 +++++----- .../vue_code/src/components/TodoList.vue | 13 +++++--- 4 files changed, 62 insertions(+), 19 deletions(-) diff --git a/20_脚手架/vue_code/src/App.vue b/20_脚手架/vue_code/src/App.vue index d72f08e..5371cf3 100644 --- a/20_脚手架/vue_code/src/App.vue +++ b/20_脚手架/vue_code/src/App.vue @@ -2,8 +2,8 @@
- - + +
@@ -22,6 +22,30 @@ export default { TodoHeader, TodoList, TodoBottom + }, + data() { + return { + todos: [ + {id: "001", title: "产品", done: true}, + {id: "002", title: "开发", done: true}, + {id: "003", title: "测试", done: false} + ] + } + }, + methods: { + addTodo(todoObj) { + this.todos.unshift(todoObj) + }, + + checkTodo(id) { + this.todos.forEach((todo) => { + if (todo.id === id) todo.done = !todo.done + }) + }, + + deleteTodo(id) { + + } } } @@ -59,10 +83,11 @@ body { outline: none; } -.todo-container{ +.todo-container { width: 600px; margin: 0 auto; } + .todo-container .todo-wrap { padding: 10px; border: 1px solid #ddd; diff --git a/20_脚手架/vue_code/src/components/TodoHeader.vue b/20_脚手架/vue_code/src/components/TodoHeader.vue index acfc63a..c967cd1 100644 --- a/20_脚手架/vue_code/src/components/TodoHeader.vue +++ b/20_脚手架/vue_code/src/components/TodoHeader.vue @@ -1,12 +1,29 @@ diff --git a/20_脚手架/vue_code/src/components/TodoItem.vue b/20_脚手架/vue_code/src/components/TodoItem.vue index d5ea487..f3f66e0 100644 --- a/20_脚手架/vue_code/src/components/TodoItem.vue +++ b/20_脚手架/vue_code/src/components/TodoItem.vue @@ -1,8 +1,8 @@