File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 <ul >
66 <li v-repeat =" todo : todos" >
77 <input type =" checkbox" v-model =" todo.completed" >
8- <label >{{ todo.title }}</label >
8+ <label v-on =" dblclick: todo.editing = true"
9+ v-show =" !todo.editing" >{{todo.title}}</label >
10+ <input v-model =" todo.title"
11+ v-on =" blur:save(todo), keyup:save(todo) | key 'enter'"
12+ v-show =" todo.editing" >
13+ <a v-on =" click:remove(todo)" >[x]</a >
914 </li >
1015 </ul >
1116</template >
@@ -21,9 +26,19 @@ export default {
2126 add () {
2227 var value = this .input .trim ();
2328 if (value) {
24- this .todos .push ({title: value, completed: false });
29+ this .todos .push ({title: value, completed: false , editing : false });
2530 this .input = ' ' ;
2631 }
32+ },
33+ save (todo ) {
34+ todo .editing = false ;
35+ todo .title = todo .title .trim ();
36+ if (! todo .title ) {
37+ this .remove (todo);
38+ }
39+ },
40+ remove (todo ) {
41+ this .todos .$remove (todo);
2742 }
2843 }
2944};
You can’t perform that action at this time.
0 commit comments