File tree Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Original file line number Diff line number Diff line change 44
55## TODO list
66简单 ` TODO List ` 实现。掌握表单绑定,class 绑定,事件绑定。
7- [ 代码地址] ( . /todo.html)
7+ [ 代码地址] ( http://htmlpreview.github.io/?https://github.com/Flyerboy/vue-demo/blob/master /todo.html)
88
99## 树结构
1010树结构的新增,编辑,删除,选中功能的实现。
11- [ 代码地址] ( ./tree.html )
11+ [ 代码地址] ( http://htmlpreview.github.io/?https://github.com/Flyerboy/vue-demo/blob/master/tree.html ) 。
12+
1213这个例子前提是必须了解 ` components ` 的使用, 变量值是怎么传递使用的,递归的使用,和 ` $parent ` ,` $root ` 这些知识点。
1314
1415## 笔记本
1516笔记的新增,编辑,删除,收藏功能的实现。
1617中间使用 ` markdown ` 来实现笔记的展示。
17- [ 代码地址] ( . /note.html)
18+ [ 代码地址] ( http://htmlpreview.github.io/?https://github.com/Flyerboy/vue-demo/blob/master /note.html)
1819
1920这个例子主要使用了多个组件,` vue-router ` 知识的使用。
2021
2122
22-
2323## 购物车功能
2424购物车添加,编辑,删除,计算总价功能的实现。
25- [ 代码地址] ( . /cart.html)
25+ [ 代码地址] ( http://htmlpreview.github.io/?https://github.com/Flyerboy/vue-demo/blob/master /cart.html)
Original file line number Diff line number Diff line change @@ -18,9 +18,10 @@ <h3 class="text-center">TODO list</h3>
1818 < input type ="text " class ="form-control " v-model ="name " @keyup.enter ="createTodo() ">
1919
2020 < br />
21- < ul class ="list-group ">
21+ < ul class ="list-group form-inline ">
2222 < li class ="list-group-item " v-for ="row in lists " :class ="{'disabled': row.checked} ">
23- {{ row.name }}
23+ < input type ="text " class ="form-control " v-model ="row.name " v-if ="row.isEdit " @blur ="updateTodo(row) ">
24+ < span v-if ="!row.isEdit "> {{ row.name }}</ span >
2425 < span class ="pull-right ">
2526 < a class ="glyphicon glyphicon-edit text-primary " href ="javascript:; " @click ="editTodo(row) "> </ a >
2627 < a class ="glyphicon glyphicon-trash text-danger " href ="javascript:; " @click ="removeTodo(row) "> </ a >
@@ -43,16 +44,26 @@ <h3 class="text-center">TODO list</h3>
4344 this . lists . push ( {
4445 id : this . k ,
4546 name : this . name ,
46- checked : false
47+ checked : false ,
48+ isEdit : false
4749 } ) ;
4850 this . k = this . k + 1 ;
4951 this . name = '' ;
5052 } ,
5153 editTodo : function ( todo ) {
52-
54+ todo . isEdit = true ;
55+ } ,
56+ updateTodo : function ( todo ) {
57+ todo . isEdit = false ;
58+ //TODO 数据提交
5359 } ,
5460 removeTodo : function ( todo ) {
55-
61+ var _this = this ;
62+ this . lists . forEach ( function ( item , index ) {
63+ if ( item . id == todo . id ) {
64+ _this . lists . splice ( index , 1 ) ;
65+ }
66+ } ) ;
5667 }
5768 }
5869 } ) ;
You can’t perform that action at this time.
0 commit comments