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 @@