-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
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
react 禁止“事件冒泡” #9
Labels
Comments
omg |
@simongfxu 是如何处理的呐? |
@Thinking80s 文章已过时,React现在已经没有这个问题了。 |
大概是什么原理呢? |
我用的event.stopPropagation()是可以阻止事件冒泡的 |
给 Icon 加个样式 pointer-events: none 就能直接解决 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
标题的说法其实不太准确,因为react原生的事件系统本身就是事件代理的,意味着事件会一直冒泡到document进行绑定。所以,使用普通的**event.stopPropagation();**是没有办法在react中实现阻止事件“冒泡”类似的操作的。
stackoverflow和github issue上都有相关的讨论,比如
最后我找到了一个比较简单地解决方法,就是 react-native-listener。
参考地址:https://www.npmjs.com/package/react-native-listener
The text was updated successfully, but these errors were encountered: