+
- 已完成0/全部2
+ 已完成{{ totalDone }}/全部{{ total }}
-
+
\ No newline at end of file
diff --git a/20_脚手架/vue_code/src/components/TodoHeader.vue b/20_脚手架/vue_code/src/components/TodoHeader.vue
index c967cd1..b0c7dca 100644
--- a/20_脚手架/vue_code/src/components/TodoHeader.vue
+++ b/20_脚手架/vue_code/src/components/TodoHeader.vue
@@ -11,11 +11,14 @@ export default {
name: "TodoHeader",
props: ['addTodo'],
data() {
+ // 初始化title已显示placeholder内容
return {
title: ''
}
},
methods: {
+ // 添加todo任务,trim用户输入数据后判断是否为空,如果内容正常则生成任务的对象数据
+ // 将任务的对象数据回写到App中的todo中
add() {
if (!this.title.trim()) return alert("输入不能为空")
const todoObj = {id: nanoid(), title: this.title, done: false}
diff --git a/20_脚手架/vue_code/src/components/TodoItem.vue b/20_脚手架/vue_code/src/components/TodoItem.vue
index f3f66e0..b565bdc 100644
--- a/20_脚手架/vue_code/src/components/TodoItem.vue
+++ b/20_脚手架/vue_code/src/components/TodoItem.vue
@@ -2,19 +2,27 @@
-
+
@@ -27,6 +29,7 @@ export default {
border-radius: 2px;
padding: 0px;
}
+
.todo-empty {
height: 40px;
line-height: 40px;