var filters = {
all: function (todos) {
return todos
},
active: function (todos) {
return todos.filter(function (todo) {
return !todo.completed
})
},
completed: function (todos) {
return todos.filter(function (todo) {
return todo.completed
})
}
}
filteredTodos: function () {
return filters[this.visibility](this.todos)
},
I would like to ask how the filteredTodos method calls the filters method to have an array? What is the usage? Please solve your doubts~
filters[this.visibility]This is not an array, but a method under the calling object.this.visibility的结果可能有三个all,active,completedSo it ends up being something like this:filters['all']就相当于调用了filters对象下的all方法,因为this.visibilityis a variable, so it must be written like this