Vue中取消事件冒泡的方式
1. 使用event
function boxHandler(event,msg){
event.stopPropagation();//取消事件传播
alert(msg)
}
2. 使用vue提供的stop
function boxHandler2(msg){
alert(msg)
}
<div class="box1" @click="boxHandler2('box1')">
box1
<div class="box2" @click.stop="boxHandler2('box2')">
box2
<div class="box3" @click.stop="boxHandler2('box3')">
box3
</div>
</div>
</div>