Skip to content

Commit 707e8ee

Browse files
committed
update
1 parent 894c0f2 commit 707e8ee

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
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)

todo.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff 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>&nbsp;&nbsp;
@@ -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
});

0 commit comments

Comments
 (0)