Vue-click事件
Vue-click事件(此外事件还有mouseover,mouseout,dblclick,mousdown...):v-on:click="函数"v-on:click/mouseout/mouseover/dblclick/mousedown.....new Vue({el:'#box',data:{ //数据 arr:['apple','banana','oran
Vue-click事件(此外事件还有mouseover,mouseout,dblclick,mousdown...):
v-on:click="函数"
v-on:click/mouseout/mouseover/dblclick/mousedown.....
new Vue({
el:'#box',
data:{ //数据
arr:['apple','banana','orange','pear'],
json:{a:'apple',b:'banana',c:'orange'}
},
methods:{
show:function(){ //方法
alert(1);
}
}
});
<div id="box">
<input type="button" value="按钮" v-on:click="show()">
</div>
实例(vue点击添加)
<script>
window.onload=function(){
new Vue({
el:'#box',
data:{ //数据
arr:['apple','banana','orange','pear'],
json:{a:'apple',b:'banana',c:'orange'}
},
methods:{
add:function(){
this.arr.push('tomato');
}
}
});
};
</script>
<div id="box">
<input type="button" value="按钮" v-on:click="add()">
<br>
<ul>
<li v-for="value in arr">
{{value}}
</li>
</ul>
</div>
更多推荐
所有评论(0)