我有这样的课
var grid = function () {
this.cell = null;
this.loadImage = function () {
var image = new Image();
var object = this;
image.src = "blah";
$(image).load(function () {
object.cell = this;
});
}
this.showImage = function () {
alert(object.cell); // This should print [object Object] ... but it print null;
}
}
在从 loadImage 函数加载调用的图像之后调用 showImage 函数。有谁知道为什么 object.cell 为空...我在 loadImage 中引用了这个对象。