mirror of https://github.com/vuejs/vue.git
comments for todomvc example
This commit is contained in:
parent
c42e185960
commit
78293a5ab9
|
|
@ -1,7 +1,10 @@
|
||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
|
|
||||||
|
// the root element that will be compiled
|
||||||
el: '#todoapp',
|
el: '#todoapp',
|
||||||
|
|
||||||
|
// a custom directive to wait for the DOM to be updated
|
||||||
|
// before focusing on the input field.
|
||||||
directives: {
|
directives: {
|
||||||
'todo-focus': function (value) {
|
'todo-focus': function (value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
|
|
@ -11,6 +14,8 @@ var app = new Vue({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// the `created` lifecycle hook.
|
||||||
|
// it will be called when the ViewModel instance is created.
|
||||||
created: function () {
|
created: function () {
|
||||||
this.filters = {
|
this.filters = {
|
||||||
all: function (todo) { todo.completed; return true },
|
all: function (todo) { todo.completed; return true },
|
||||||
|
|
@ -26,8 +31,13 @@ var app = new Vue({
|
||||||
}).length
|
}).length
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// data
|
||||||
data: {
|
data: {
|
||||||
|
|
||||||
|
// fetch the saved todos from localStorage
|
||||||
todos: todoStorage.fetch(),
|
todos: todoStorage.fetch(),
|
||||||
|
|
||||||
|
// a computed property with custom getter/setter
|
||||||
allDone: {
|
allDone: {
|
||||||
$get: function () {
|
$get: function () {
|
||||||
return this.remaining === 0
|
return this.remaining === 0
|
||||||
|
|
@ -42,6 +52,8 @@ var app = new Vue({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// methods that implement data logic.
|
||||||
|
// note there's no DOM manipulation here at all!
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
updateFilter: function () {
|
updateFilter: function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue