在vue中实现事件绑定的方式有:1.通过v-on指令绑定;2.使用methods方法绑定;3.通过v-show指令绑定;

在vue中实现事件绑定的方式有以下几种
1.通过v-on指令绑定事件
[removed] = function () { var c = new Vue({
el : 'body',
methods : {
say : function(){
alert( '事件绑定' );
}
}
});
}
<input type="button" value="点我" v-on:click="say();"/>
2.使用methods方法绑定事件
[removed] = function () { var c = new Vue({
el : 'body',
data : {
arr : [ 10, 20, 30 ]
},
methods : {
change : function(){
this.arr.push( 40 );
}
}
});
}
<input type="button" value="点我" v-on:dblclick="change();"/>
- {{value}}
3.通过v-show指令绑定事件
<style>div {
width: 200px;
height: 200px;
background: red;
float:left;
margin:20px;
}
</style>
[removed][removed]
[removed]
[removed] = function () {
var c = new Vue({
el : 'body',
});
}
[removed]