默认情况下,事件在h5页面会穿透传递,比如一div里面套一个div,点击上层div,下层div也会响应
要阻止事件穿透,使用event.stopPropagation();
代码示例:
<div @click="testout($event)>
<div @click="testin($event)"></div>
</div>
.......
testin(event) {
......
event.stopPropagation();
},
默认情况下,事件在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
网友评论