bindtap,catchtap事件绑定的区别,这里就涉及冒泡事件了。bind事件绑定不会阻止冒泡事件向上冒泡,catch事件绑定可以阻止冒泡事件向上冒泡。
logs.wxml
<view class="view1" bindtap="view1"> view1 <view class="view2" bindtap="view2"> view2 <view class="view3" catchtap="view3">view3</view> </view> </view>
logs.js
view1: function () { console.log("---view1 bindtap click") }, view2: function () { console.log("--view2 bindtap click") }, view3: function () { console.log("-view3 catchtap click ") }
点击view3
-view3 catchtap click
点击view2
--view2 bindtap click
---view1 bindtap click
点击view1
---view1 bindtap click