0

Can you please help me clarify the difference between v-on.stop and v-on.prevent? Both are used to prevent default event, but not sure about the difference.

Vinay Bedre
  • 366
  • 1
  • 6
  • 16

1 Answers1

3

Both are used to prevent default event

That is not true:

  1. v-on.stop = event.stopPropagation() - it is used to stop bubbling, so if you have a parent and a child and they both have a click event, and when clicking the child you only want it's event to happen, you'll use this.
  2. v-on.prevent = event.preventDefault - it is used to prevent the default behavior of the clicked element, so if you clicked an a tag, it will prevent it from going to the link it points to.
Tomer
  • 17,787
  • 15
  • 78
  • 137