与coffeescript绑定

car*_*sel 7 bind coffeescript

如何用coffeescript调用function-object的native bind方法?这是我想要实现的例子:

window.addEventListener("load",function(e){
    this._filter(true);
    }.bind(this);
 )
Run Code Online (Sandbox Code Playgroud)

mu *_*ort 11

只需在函数周围添加一些括号,这样就可以做到.bind正确:

window.addEventListener('load', ((e) ->
    this._filter(true)
).bind(this))
Run Code Online (Sandbox Code Playgroud)

这将使用本机bind方法,而不是var _this = thisCoffeeScript =>使用的常用技巧.