<div class="min " name="">-</div> <input class="text-box" name="pricenum" type="tel" v-model="counter" placeholder="请输入价格" onkeyup="onKeyPrice(this);" maxlength="12 " /><div class="add" name="">+</div>
1 回答
翻翻过去那场雪
TA贡献2065条经验 获得超13个赞
<div id="app">
<div class="min" name="" v-on:click="min">-</div>
<input class="text-box" name="pricenum" type="tel" v-model="counter" placeholder="请输入价格" maxlength="12 " />
<div class="add" name="" v-on:click="add">+</div>
</div>
new Vue({
el: '#app',
data: {
counter: 0,
},
methods: {
add: function() {
this.counter = parseInt(this.counter) + 1;
},
min: function(){
if(this.counter > 0){
this.counter = parseInt(this.counter) - 1;
}
}
}
})
添加回答
举报
0/150
提交
取消