自定义组件bubbles为false时并没有阻止事件冒泡

发布于 6 年前作者 qianjun13095 次浏览最后编辑 6 年前来自 ask

给组件自定义事件时,设置bubbles为true和false表现一致,并没有阻止事件冒泡。

this.triggerEvent(‘customevent’,{e},{  });

this.triggerEvent(‘customevent’,{ e }, { bubbles:true });

https://developers.weixin.qq.com/s/QwB5g2mL7D4z

希望只触发 customevent 事件,不触发外层view上绑定的tap事件。

1 回复
oxia
oxia1 楼4 年前

使用 triggerEvent 将触发另一个与 tap 无关的独立事件。如果需要阻止 touch 事件冒泡,请使用 catchtap 。