嗯,在这种情况下如何使OnLoad异步?
否则我必须在OnLoad闭包中输入许多代码。
$.each(data, function() {
albumPhoto = 'http://assets.example.com/' + this.photo;
var temp_img = new Image(),
albumPhotoWidth, albumPhotoHeight
temp_img.src = albumPhoto;
temp_img.onload = function() {
console.log(this.naturalWidth) // have something
albumPhotoWidth = this.naturalWidth;
albumPhotoHeight = this.naturalHeight;
}
console.log(albumPhotoWidth) //undefined ?? I want to use it here
});