<html>
head>
script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</bodydiv id="app">
button @click="sub">-buttonspan>{{number}}="add">+div>
var app = new Vue({
el: '#app',data: {
number: 0
},methods: {
sub: function () {
if (this.number != 0) {
this.number -= 1;
} else {
alert("不能再减少了");
}
},add: function () {
if (this.number 10) {
this.number += 1;
} else {
alert("不能再增加了");
}
},},})
</script>
>