0
변수의 범위에 문제가 있습니다. 처음 두 값은 올바른 값을 반환하지만 이벤트에 가입하면 (이벤트가 작동 중임) this._id가 정의되지 않은 값으로 반환됩니다. 나는 또한 MyFunction._id로 시도했다.범위 지정 기능 내에서의 문제
var i = 0;
var func = new MyFunction();
func.init();
function MyFunction(i){
this._id = i;
}
MyFunction.prototype.init = function(){
Debugger.log("A : " + this._id); //displays the result of i
this.myTest; //displays the result of i
Event.subscribe("UPDATE", this.myTest);// is undefined
}
MyFunction.prototype.myTest = function(){
Debugger.log("B : " + this._id);
}
thx.