方法一:使用vue阻止子级元素的click事件冒泡.
<div @click="testFather()">
<span @click.stop="testChild()">按钮test</span>
<span>按钮2</span>
</div>
这样点击div里面的【按钮test】,就不会触发div绑定时间testFather()方法。方法二:可以自己写个阻止冒泡事件 然后在发生冒泡的元素中调用这个事件
@click="_stopPropagation($event)"methods:{
_stopPropagation(ev){
var _this = this;
ev.stopPropagation();
},
}
https://blog.csdn.net/weixin_42365757/article/details/119917017
您已经阅读00:00:00欢迎留言评论,喜欢的话就为作者点个赞或者赏颗糖吧! 分享
发表评论(不少于3个字符) 取消回复