3
Ich studiere Backbone n Unterstreichung.
jemand mir helfen.
Ich weiß nicht, dass das Modell von _.each() undefiniert ist.Was ist der Unterschied zwischen Unterstrich _.each und forEach?
var todos = new Backbone.Collection();
todos.add([
{ title: 'go to Belgium.', completed: false },
{ title: 'go to China.', completed: false },
{ title: 'go to Austria.', completed: true }
]);
// iterate over models in the collection
todos.forEach(function(model){
console.log(model.get('title'));
});
// Above logs:
// go to Belgium.
// go to China.
// go to Austria.
Warum Modell ist nicht definiert ???
/*underscoreJS model is undefined...*/
_.each(todos, function (model) {
console.log(model.get('title'));
});
Backbone hat einen Proxy der '_.each' Methode, den Sie in Ihrem Fall verwenden müssen:' todos.each (function (todo) {...}) ' – hindmost