1414 <!-- 通过 enter 修饰符,当回车时 -->
1515 </header >
1616 <section class =" main" >
17- <input id =" toggle-all" class =" toggle-all" type =" checkbox" />
17+ <input
18+ id =" toggle-all"
19+ class =" toggle-all"
20+ type =" checkbox"
21+ :checked =" allDoneRef"
22+ @input =" setAllChecked($event.target.checked)"
23+ />
24+ <!-- 事件源(checkbox)的勾选状态,true/false -->
1825 <!-- checkbox 是设置了背景图 ⭕️ ,然后设置了本体完全透明(点击仍是本体处理 -->
1926 <label for =" toggle-all" >Mark all as complete</label >
2027 <ul class =" todo-list" >
2128 <li
2229 class =" todo"
23- :class =" { completed: todo.completed }"
30+ :class =" { completed: todo.completed, editing: todo === nowEditing }"
2431 v-for =" todo in filteredTodoRef"
2532 :key =" todo.id"
2633 >
27- <!-- li 自带类样式 completed -->
34+ <!-- li 自带类样式 completed 和 editing -->
2835 <div class =" view" >
2936 <input class =" toggle" type =" checkbox" v-model =" todo.completed" />
30- <label >{{ todo.title }}</label >
37+ <label @dblclick =" () => handleDBLClick(todo)" >{{
38+ todo.title
39+ }}</label >
40+ <!-- double left click -->
3141 <button class =" destroy" ></button >
3242 </div >
33- <input class =" edit" type =" text" />
43+ <input
44+ class =" edit"
45+ type =" text"
46+ v-model =" todo.title"
47+ @blue =" doneEdit"
48+ @keyup.enter =" doneEdit"
49+ @keyup.escape =" () => cancelEdit(todo)"
50+ />
51+ <!-- 双向绑定之后,todoRef 变化 => 自动执行监控副作用 todoStorage.saveTodos -->
3452 </li >
3553 </ul >
3654 </section >
6886</template >
6987
7088<script >
71- import { useNewTodo , useTodoList , useFilter } from " ../compositions" ;
89+ import {
90+ useNewTodo ,
91+ useTodoList ,
92+ useFilter ,
93+ useEditTodo ,
94+ } from " ../compositions" ;
7295
7396export default {
7497 setup () {
@@ -78,6 +101,7 @@ export default {
78101 todoRef,
79102 ... useNewTodo (todoRef),
80103 ... useFilter (todoRef),
104+ ... useEditTodo (todoRef),
81105 };
82106 },
83107};
0 commit comments