• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in Vue.JS by
Q:
How do you use event handlers in VueJS?

1 Answer

0 votes
by
You can use event handlers in vue similar to plain javascript. The method calls also support the special $event variable.

<button v-on:click="show('Welcome to VueJS world', $event)">

  Submit

</button>

methods: {

  show: function (message, event) {

    // now we have access to the native event

    if (event) event.preventDefault()

    console.log(message);

  }

}

Related questions

0 votes
asked Feb 4, 2020 in Vue.JS by rajeshsharma
0 votes
asked Jul 2, 2019 in React JS by Venkatshastri
...