Vue事件修饰符
视频地址:https://www.bilibili.com/video/BV1Zy4y1K7SH?p=15
stop阻止事件冒泡
prevent阻止默认事件
once
首先回顾一下什么是事件冒泡,当鼠标点击button按钮的时候,同时也点击了div,所以showInfo1和showInfo两个函数会同时被调用
<style> .a { height: 200px; background-color: skyblue; } style>
<body> <div id="h1" v-on:click="showInfo1" class="a"> <button v-on:click="showInfo">点击button> div> <script type="text/javascript"> var vm = new Vue({ el: "#h1", methods: { showInfo() { alert("showInfo~") }, showInfo1() { alert("showInfo1~") } } }) script> body>
once
Document