1๐
Your code should work fine as demonstrated below :
Vue.config.devtools = false;
Vue.config.productionTip = false;
new Vue({
el: '#app',
data: function() {
return {
count: 1
}
},
methods: {
add(by) {
let res = parseInt(this.count) + parseInt(by);
this.count = res;
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="app" class="container">
<button type="button" class="countpicker-dec" @click="add(-1)" :disabled="count < 2">-</button>
<input type="number" class="countpicker-num" v-model.number="count">
<button type="button" class="countpicker-inc" @click="add(+1)">+</button>
<div>{{count}}</div>
</div>
๐คuser15118714
- [Vuejs]-Is there a method to update a data object from vue when the database updates?
- [Vuejs]-Vue.js on render populate content dynamically via vue.router params
1๐
add() {
this.count += 1;
}
If just add to increment by 1 ..why pass by parameter just increases in method
๐คshalini
- [Vuejs]-Json array passing through Larvel Vue but not working as intended
- [Vuejs]-Is it possible to use local storage to save navigation-drawer visibility?
1๐
To show the meaning this.count
use
<p>{{this.count}}</p>
Shows the value you entered
<input type="number" class="countpicker-num" v-model.number="count">
๐คOleksii Zelenko
Source:stackexchange.com