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
第1384天 bindtap和catchtap有什么区别?
3+1官网
我也要出题
The text was updated successfully, but these errors were encountered:
当子元素使用bindtap绑定事件后,执行的时候,会冒泡到父元素(触发父元素上绑定的bingtap事件)
catchtap 不会向上冒泡到父元素
Sorry, something went wrong.
在小程序中,bindtap 和 catchtap 都是用于绑定点击事件的指令,它们的主要区别在于事件冒泡和事件捕获的处理方式。
bindtap
catchtap
bindtap 是事件冒泡,点击子元素会先触发子元素的事件,再触发父元素的事件。
catchtap 是事件捕获,点击子元素时,父元素和子元素都会触发事件,但子元素的事件会先触发,父元素的事件会后触发。
通俗地说,如果一个元素上同时绑定了 bindtap 和 catchtap,那么点击该元素的子元素时,子元素的事件先触发,父元素的事件后触发,且点击该元素本身时,只有 bindtap 事件会触发,catchtap 事件不会触发。
在实际开发中,可以根据需要来选择使用 bindtap 还是 catchtap,一般来说,如果需要子元素的事件先触发,可以使用 bindtap,如果需要父元素的事件先触发,可以使用 catchtap。
No branches or pull requests
第1384天 bindtap和catchtap有什么区别?
3+1官网
我也要出题
The text was updated successfully, but these errors were encountered: