结果:outerCapture outerBubble
先触发捕获事件,再触发冒泡事件
结果:outerCapture innerCaputure innerBubble outerBubble
先触发捕获事件,再触发冒泡事件
bind事件绑定不会阻止冒泡事件向上冒泡,catch事件绑定可以阻止冒泡事件向上冒泡。 如果将上面代码中的第一个capture-bind改为capture-catch,将只触发handleTap2(capture-catch将中断捕获阶段和取消冒泡阶段)
<view bindtap="topBubble" capture-bind:tap="topCapture"> 祖先节点 <view id="outer" catch:touchstart="outerBubble" capture-bind:touchstart="outerCapture"> 如果将上面代码中的第一个capture-bind改为capture-catch,将只触发handleTap2(capture-catch将中断捕获阶段和取消冒泡阶段) <view id="inner" bind:touchstart="innerBubble" capture-bind:touchstart="innerCaputure"> inner view </view> </view> </view> Page({ topBubble: function () { console.log("topBubble"); }, topCapture: function () { console.log("topCapture"); }, outerCapture: function () { console.log("outerCapture"); }, outerBubble: function () { console.log("outerBubble"); }, innerCaputure: function () { console.log("innerCaputure"); }, innerBubble: function () { console.log("innerBubble"); } })结果:topCapture topBubble
先触发捕获事件,再触发冒泡事件
结果:outerCapture outerBubble
catch:touchstart 阻止事件冒泡
结果:outerCapture innerCaputure innerBubble outerBubble
先触发捕获事件,再触发冒泡事件