我的callback
功能有问题
project.prototype.getFolder = function(path){
this.imagePath;
var instance = this;
function getImage(image, callback) {
var it = function(i){
codes.....
//I am sure variable image is not null
callback(image);
codes....
}
}
// function to get the image
getImage(image, function (img) {
instance.imagePath = img;
});
//it outputs undefined...
console.log(this.imagePath )
}
我想将值分配给函数this.imagePath
内部callback
,但似乎我得到undefined
了我的情况。我确定我传递image
了有效的变量,但我仍然一无所获。任何人都可以提供小费吗?非常感谢!