Backbonejs集的长度始终为零 [英] Backbonejs collection length always zero
本文介绍了Backbonejs集的长度始终为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在集合视图功能:
addAll: function() {
console.log(this.collection);
console.log(this.collection.length);
console.log(this.collection.models);
this.collection.each(this.addOne);
},
为什么结果是:
1
d
_byCid: Object
_byId: Object
length: 6
models: Array[6]
__proto__: x
2。
0
2. 0
3。
[]
3. []
我们可以看到this.collection在第一个结果模型和长度= 6
we can see the this.collection have models and length = 6 in the first result
推荐答案
谨防<一个href=\"http://stackoverflow.com/questions/9911637/backbone-js-model-get-returning-undefined-even-though-i-can-see-the-attribut/9912865#9912865\">console.log能骗你
这篇关于Backbonejs集的长度始终为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文