We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
前几天在使用ES6的时候发现箭头函数中,事件无法通过this获取本身,后来查了一些资料是这样的:
ES6
this
一般来说,this 和 event.currentTarget是一致的。 但是,如果使用了某种作用域替换,(比如jquery.Proxy,或者 ES6、CoffeeScript 等里用了 =>),this可能有别的含义了,用 event.currentTarget 就更安全。 一般人们更容易混淆的是 event.target 和 event.currentTarget。
event.currentTarget
jquery.Proxy
CoffeeScript
=>
event.target
The text was updated successfully, but these errors were encountered:
No branches or pull requests
一般来说,
this
和event.currentTarget
是一致的。但是,如果使用了某种作用域替换,(比如
jquery.Proxy
,或者ES6
、CoffeeScript
等里用了=>
),this
可能有别的含义了,用event.currentTarget
就更安全。一般人们更容易混淆的是
event.target
和event.currentTarget
。The text was updated successfully, but these errors were encountered: