我遇到了麻烦
感谢 Rodik,我对如何做到这一点有了一些大致的了解。但是,我仍然不确定如何将img
值传递给getImage
function
...
project.prototype.getImagePath = function(){
codes...
this.getFolder(path);
//how do I get the img value inside my getImage function?
}
project.prototype.getFolder = function(path){
this.imagePath;
var instance = this;
var images = ['http://project/path.png', 'http://project2/path.png'];
function getImage(images, callback) {
var iterator = function (i) {
if (i < images.length) {
var image = newImage();
//..codes to check if image path is valid
//if valid, pass image back
callback(image);
}
iterator(++i);
}
}
iterator(0);
}
getImage(images, function (img) {
console.log(img) //output the img
instance.imagePath = img
});
}
谢谢各位帮忙~~