Home » Vue.js onclick Event Handling Example

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:  Laravel 7 Guzzle Http Client Request Example

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:  Laravel update multiple rows with different values

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:  CKEditor Images Upload using Yii2 - TinyMCE
  2. Read Also:  Laravel Global Variables Example Tutorial From Scratch
  3. Read Also:  Create Google AdSense Account Help
  4. Read Also:  Toopics instagram viewer
  5. Read Also:  Laravel 6 create zip archive file and download example
  6. Read Also:  Simple Pagination with Laravel and MySQl
  7. Read Also:  Linux Crontab Unix Linux Command examples
  8. Read Also:  how to allow only 10 digit mobile number validation using javascript with jquery
  9. Read Also:  how to allow only 10 digit mobile number validation using javascript with jquery
  10. Read Also:  Laravel Global Variables Example Tutorial From Scratch

Leave a Comment

Your email address will not be published. Required fields are marked *