Simple click function to increase and decrease values of two buttons using Vue js
Add button inside template component
<button @click="increment" >{{count}}</button>
<button @click="decrement" >{{dcount}}</button>
Inside script tags add the following
<script>
export default {
data() {
return {
count: 0,
dcount: 100
}
},
methods: {
increment() {
// update component state
this.count++
},
decrement() {
this.dcount--
}
}
}
</script>
Comments
Post a Comment