如何使用coffeescript调用function-object的本地绑定方法?这是我试图实现的示例:
window.addEventListener("load",function(e){
this._filter(true);
}.bind(this);
)发布于 2013-06-22 23:12:07
只需在函数两边添加一些括号,这样您就可以.bind正确的内容:
window.addEventListener('load', ((e) ->
this._filter(true)
).bind(this))这将使用原生bind方法,而不是CoffeeScript的=>通常使用的var _this = this技巧。
https://stackoverflow.com/questions/17251063
复制相似问题