下面的代码可以工作,但我觉得还有更好的方法。我正在传递对高阶函数范围的引用。
var p=this;
this.nodeModal.find(".modal-footer .save").click(function(){
p.saveAndClose();
});
是否有更简单的方法来传递高阶函数的引用?某种绑定(bind)?
最佳答案
或者,如果您使用的是 ES6,带有箭头函数:
this.nodeModal.find(".modal-footer .save").click(() => {
this.saveAndClose();
});
关于javascript - 高阶函数引用JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36680038/