Program:
index.html:
index.js:
Output:
index.html:
<!DOCTYPE html>
<html>
<body>
<div id="ad">
{{ temp }}
<button v-on:click="inc"> + </button>
<button v-on:click="dec"> - </button>
</div>
<script src="https://unpkg.com/vue"></script>
<script type="text/javascript" src="./index.js"> </script>
</body>
</html>
index.js:
var app = new Vue({
el: '#ad',
data: {
temp: 0,
},
methods: {
inc: function () {
this.temp++;
},
dec: function () {
this.temp--;
}
}
});
Output:
