4 Program to demonstrate Events in VueJS

Program:

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:

Events in VueJS

Previous
Next Post »