解决办法:
dbclick
改为dblclick
即可:
实例代码:
<div id="app">
<p>马云的年龄:{{age}}岁</p>
<input type="button" @dblclick='reduce(10)' value="减少10岁">
<input type="button" @dblclick='increase(10)' value="增加10岁">
</div>
<script src="vue.js"></script>
<script>
let vm=new Vue({
el:"#app",
data:{
age:50
},
methods: {
increase:function(num){
if(this === vm){
this.age += num;
}
},
reduce:function(num){
if(this === vm){
this.age -= num;
}
},
},
});
</script>
实现效果:
注:由于GIF帧数问题,看起来像是单击,实际是双击