Fre*_*all 7 jquery coffeescript arrow-functions
这非常有效
@nav.on 'click', ->
_this.mover _this.nav.index $(@)
Run Code Online (Sandbox Code Playgroud)
但我想知道我是否可以使用胖箭而不是这样
@nav.on 'click', =>
@mover @nav.index $(????)
Run Code Online (Sandbox Code Playgroud)
但我会落实到位@,这将导致this代替_this?
mu *_*ort 15
jQuery的事件处理程序获得的事件对象作为参数,该事件对象有target和currentTarget属性:
@nav.on 'click', (ev) =>
@mover @nav.index $(ev.currentTarget)
Run Code Online (Sandbox Code Playgroud)
根据您的具体情况,您可能需要其他属性之一ev.