无法从匿名函数处理程序中的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