無法從匿名函數處理程序中的fx2訪問fx1?匿名事件處理程序無法訪問原型方法
var MyComponent = function() {
//my constructor
}
MyComponent.prototype.fx1 = function() { //code }
MyComponent.prototype.fx2 = function() {
var btn1 = document.getElementById('Button1')
btn1.onclick = function() {
//issue is here
//trying to call fx1 from here but can't access it.
this.fx1(); //doesn't work.
}
}
那麼究竟你試試? – devnull69
你在哪裏訪問它? –
您遺漏了代碼 – Musa