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.
Asked
Active
Viewed 1,733 times
1 Answers
3
Both are used to prevent default event
That is not true:
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.v-on.prevent=event.preventDefault- it is used to prevent the default behavior of the clicked element, so if you clicked anatag, it will prevent it from going to the link it points to.
Tomer
- 17,787
- 15
- 78
- 137