<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
[v-cloak]{
display: none;
}
</style>
</head>
<body> <div id="app">
<div>{{num}}</div>
<div>
<button @click='handle1'>点击1</button>
<button @click='handle2(123,456,$event)'>点击2</button>
</div>
</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script type="text/javascript">
var vm = new Vue({
el:'#app',
data:{
msg:'Hello Vue',
num:0
},
methods: {
handle2:function(d1,d2){
console.log(d1,d2)
console.log(event.target.tagName) --显示button
console.log(event.target.innerHTML) --显示点击2
this.num++;
},
handle1:function(event){
console.log(event.target.innerHTML) --显示点击1
}
},
});
</script>
</body>
</html>**
VUE绑定事件
最新推荐文章于 2024-04-19 18:32:11 发布