美文网首页
vue中阻止事件穿透的方法

vue中阻止事件穿透的方法

作者: 手指乐 | 来源:发表于2019-10-12 11:09 被阅读0次

默认情况下,事件在h5页面会穿透传递,比如一div里面套一个div,点击上层div,下层div也会响应
要阻止事件穿透,使用event.stopPropagation();
代码示例:

<div @click="testout($event)>
<div @click="testin($event)"></div>
</div>
.......

testin(event) {
      ......
      event.stopPropagation();
    },

相关文章

网友评论

      本文标题:vue中阻止事件穿透的方法

      本文链接:https://www.haomeiwen.com/subject/ivqqmctx.html