Vue.js onclick Event Handling Example

Today, We want to share with you Vue.js onclick Event Handling Example.In this post we will show you Vue.js Events Tutorial, hear for Handling Events With Vue.js we will give you demo and example for implement.In this post, we will learn about how to call Vue.js function on button click in html with an example.

Vue.js onclick Event Handling Example

There are the Following The simple About Vue.js onclick Event Handling Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Vue.js event listener list, so the Vue.js event object for this example is following below.

vue Click Event

<html>
   <head>
      <title>VueJs Instance - Pakainfo.com</title>
      <script type = "text/javascript" src = "js/vue.js"></script>
   </head>
   <body>
      <div id = "databinding">
         <button v-on:click = "previewresults">Touch To RESULTS</button>
         <h2> Add Number 150 + 250 = {{total}}</h2>
      </div>
      <script type = "text/javascript">
         var vm = new Vue({
            el: '#databinding',
            data: {
               num1: 150,
               num2 : 250,
               total : ''
            },
            methods : {
               previewresults : function(event) {
                  console.log(event);
                  return this.total =  this.num1+ this.num2;
               }
            },
         });
      </script>
   </body>
</html>

index.html

<html>
   <head>
      <title>VueJs Instance - www.pakainfo.com</title>
      <script type = "text/javascript" src = "js/vue.js"></script>
   </head>
   <body>
      <div id = "databinding">
         <div v-bind:style = "backObj" v-on:mouseover = "changebgcolor" v-on:mouseout = "originalcolor"></div>
      </div>
      <script type = "text/javascript">
         var vm = new Vue({
            el: '#databinding',
            data: {
               num1: 100,
               num2 : 200,
               total : '',
               backObj : {
                  width:"300px",
                  height:"300px",
                  backgroundColor:"green"
               }
            },
            methods : {
               changebgcolor : function() {
                  this.backObj.backgroundColor = "black";
               },
               originalcolor : function() {
                  this.backObj.backgroundColor = "green";
               }
            },
         });
      </script>
   </body>
</html>

Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  Eloquent Batch update multiple records using Laravel

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Vue.js onclick Event Handling Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.