Handle DOM Events in Vue.js with v-on

Greg Thoman
InstructorGreg Thoman

Share this video with your friends

Send Tweet

v-on can be used to handle interaction with elements in your template. Modifiers like stop and prevent can be used in place to preventDefault() and stopPropagation. Vue.js can also capture key bindings such as v-on:keyup.enter and v-on:keyup.13.

themathmagician
themathmagician
~ 3 years ago

What does the .prevent do, exactly? Why is it added in the end?

Jean-Francois
Jean-Francois
~ 3 years ago

If you run the code on CodeSandbox and remove the prevent modifier, you'll notice that the form submission causes a page reload.