【发布时间】:2013-01-28 12:09:21
【问题描述】:
我以前用过
MyClass.prototype.myMethod1 = function(value) {
this._current = this.getValue("key", function(value2){
return value2;
});
};
如何在回调函数中访问 this 的值,如下所示?
MyClass.prototype.myMethod1 = function(value) {
this.getValue("key", function(value2){
//ooopss! this is not the same here!
this._current = value2;
});
};
【问题讨论】:
-
您总是可以将
this作为第二个参数传递过来。不确定它是否会起作用。 -
函数是否匿名真的没有任何关系。
标签: javascript