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.

Read Also:  how to get last inserted id in laravel 6?

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:  Vuejs Live Search Filter Example with Demo

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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Event Watch route change with VueJS
  2. Read Also:  Fixed Position Elements in CSS Examples
  3. Read Also:  JavaScript Preview Image before Upload with jQuery
  4. Read Also:  Laravel Selecting and Aliasing Columns in Eloquent's query
  5. Read Also:  Convert base64 to image VUEJS
  6. Read Also:  PHPMailer Sending Emails using PHP Code
  7. Read Also:  Laravel Grouping Cache Offset & Limit Eloquent methods
  8. Read Also:  Laravel Global variable Sharing Data with all views
  9. Read Also:  Fixed Position Elements in CSS Examples
  10. Read Also:  JavaScript Preview Image before Upload with jQuery
CLOSEX