骨干为允许输出空collection.models阵列? [英] Backbone outputing empty array for collection.models?

查看:211
本文介绍了骨干为允许输出空collection.models阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个问题,如果我做

apples = new Apples
apples.fetch()
console.log apples
console.log apples.models

的console.log苹果将出把苹果收集,使用型号:阵列(10)内上市对象。

console.log apples will out put the Apples Collection, with models: Array(10) listed inside the object.

但是,的console.log apples.models 输出一个空数组。

But, console.log apples.models outputs an empty array.

为什么会出现这种情况?

Why does this happen?

先谢谢了。

推荐答案

您试图执行fecth()方法或等待后立即CONSOLE.LOG集合回调通过使用执行

Are you trying to console.log the collection right after executing the fecth() method or waiting for the callback to be executed by using

apples.on('reset', function(){ console.log(this.models);} ,this); 

这篇关于骨干为允许输出空collection.models阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆