Skip to content

Commit 78293a5

Browse files
author
Evan You
committed
comments for todomvc example
1 parent c42e185 commit 78293a5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

examples/todomvc/js/app.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
var app = new Vue({
22

3+
// the root element that will be compiled
34
el: '#todoapp',
45

6+
// a custom directive to wait for the DOM to be updated
7+
// before focusing on the input field.
58
directives: {
69
'todo-focus': function (value) {
710
if (value) {
@@ -11,6 +14,8 @@ var app = new Vue({
1114
}
1215
},
1316

17+
// the `created` lifecycle hook.
18+
// it will be called when the ViewModel instance is created.
1419
created: function () {
1520
this.filters = {
1621
all: function (todo) { todo.completed; return true },
@@ -26,8 +31,13 @@ var app = new Vue({
2631
}).length
2732
},
2833

34+
// data
2935
data: {
36+
37+
// fetch the saved todos from localStorage
3038
todos: todoStorage.fetch(),
39+
40+
// a computed property with custom getter/setter
3141
allDone: {
3242
$get: function () {
3343
return this.remaining === 0
@@ -42,6 +52,8 @@ var app = new Vue({
4252
}
4353
},
4454

55+
// methods that implement data logic.
56+
// note there's no DOM manipulation here at all!
4557
methods: {
4658

4759
updateFilter: function () {

0 commit comments

Comments
 (0)