当前位置:   article > 正文

微信小程序之事件(bindtap和catchtap)_catchtap='handletap

catchtap='handletap

bindtap和catchtap都是当用户点击该组件的时候会在该页面对应的Page中找到相应的事件处理函数。但是bind事件绑定不会阻止冒泡事件向上冒泡,catch事件绑定可以阻止冒泡事件向上冒泡

  1. <view id="outer" bindtap="handleTap1">
  2. outer view
  3. <view id="middle" catchtap="handleTap2">
  4. middle view
  5. <view id="inner" bindtap="handleTap3">
  6. inner view
  7. </view>
  8. </view>
  9. Page({
  10. handleTap1:function(event){ //点击输出outer view bindtap
  11. console.log("outer view bindtap")
  12. },
  13. handleTap2: function (event) { //点击输出middle view
  14. console.log("middle view catchtap")
  15. },
  16. handleTap3: function (event) { //点击输出inner view bindtap middle view catchtap
  17. console.log("inner view bindtap")
  18. },
  19. })
  1. <view id="outer" bindtap="handleTap1">
  2. outer view
  3. <view id="middle" bindtap="handleTap2">
  4. middle view
  5. <view id="inner" bindtap="handleTap3">
  6. inner view
  7. </view>
  8. </view>
  9. Page({
  10. handleTap1:function(event){ //点击输出outer view bindtap
  11. console.log("outer view bindtap")
  12. },
  13. handleTap2: function (event) { //点击输出outer view bindtap middle view
  14. console.log("middle view catchtap")
  15. },
  16. handleTap3: function (event) { //点击输出outer view bindtap inner view bindtap middle view catchtap
  17. console.log("inner view bindtap")
  18. },
  19. })

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/218827
推荐阅读
相关标签
  

闽ICP备14008679号