vue阻止事件冒泡

xiaoxiao2021-02-28  22

<script> window.onload=function(){ new Vue({ el:'#box', data:{ }, methods:{ show:function(ev){ alert(1); ev.cancelBubble=true;//阻止事件冒泡 }, show2:function(){ alert(2); } } }); }; </script> </head> <body> <div id="box"> <div @click="show2()"> <input type="button" value="按钮" @click="show($event)"> </div> </div> </body> </html>

or @click.stop阻止冒泡

转载请注明原文地址: https://www.6miu.com/read-2628475.html

最新回复(0)