【发布时间】:2012-02-07 09:16:17
【问题描述】:
好的,刚刚解决了this refered to the wrong scope 的一个问题。现在我有另一个问题。
所以我想将 inside 的 method 称为 method .但我不知道怎么做,检查这个来源:
function someObj() {
var self = this;
this.someMethod1 = function() {
var elementBtn = document.getElementById('myBtn');
elementBtn.onclick = function() {
self.someMethod2.methodMethod();
//I want this.someMethod2.methodMethod() to be called
//...but I get an big error instead. Is it even possible?
//this.someMethod2() works fine.
};
};
this.someMethod2 = function() {
this.methodMethod = function() {
alert('THIS IS THE ONE I WANTED!');
};
alert('NO, NOT THIS!');
};
}
错误信息:
Uncaught TypeError: Object function () { ...
【问题讨论】:
标签: javascript javascript-objects