8). Vue.js Methods and Event Handling
We can use the v-on directive to listen to DOM events and run some JavaScript when they’re triggered. Example 1:- JS fiddle <div id="vue-instance"> Enter your name: <input type="text" v-model="name"> <button v-on:click="sayHello">Hey there!</button> </div> var vm = new Vue({ el: '#vue-instance', data: { name: '' }, methods: { sayHello: function(){ alert('Hey there, ' + this.name); } } }); Example 2:- Sometimes we also need to access the original DOM event in an inline statement handler. You can pass it into a method using the special $event variable: <button v-on:click="warn('Form can...