我有这个功能:
$(this.myObject).click(A.bind(this));
function A(){
// stuff here
}
我想从第二个函数中调用(绑定(bind) this)。
$(this.myOtherObject).click(B.bind(this));
function B(){
A(); // works but does not bind
A.bind(this); // does not work
}
我该怎么做?
最佳答案
您想使用 call(this)不是 bind() 因为 bind() 只是返回方法。
A.call(this)
关于javascript - 使用绑定(bind)调用 javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51989036/