<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>事件绑定</title>
<script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<div id="root">
<h2>{{name}}</h2>
<div @click="showInfo">
<button @click="showInfo($event)">点击我,阻止冒泡事件</button>
</div>
</div>
<script type="text/javascript">
Vue.config.productionTip = false;
const vm = new Vue({
el:'#root',
data:{
name:'虾米大王'
},
methods:{
showInfo(event){
alert('点击了我,显示提示');
event.stopPropagation();
}
}
})
</script>
</body>
</html>
vus.js代码027
最新推荐文章于 2024-06-07 10:08:27 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)