嗨我有以下代码,我在调用一个函数,该函数需要一个带参数的回调函数。基本上,我试图让e的内容进入this.items,但我不能逃避回调函数?回调函数内的访问变量
function stash(){
this.items = new Array();
this.get = function(){
opr.stash.query({},function(e){
console.log(this.items); //this is not defined
});
}
}
s = new stash();
s.get();
可能重复[如何访问正确的\'这\'/上下文内回调?](http://stackoverflow.com/questions/20279484/how-to-access-the-correct-this-context-inside-a-callback) –