Vue.js
Vue.js Event Modifiers
Use Vue event modifiers to control propagation, default actions, and event handling.
Vue.js provides event modifiers to simplify event handling in templates. These modifiers are added to event directives (e.g., v-on:click or @click) using dot notation (e.g., @click.stop).
-
.stop
Prevents event propagation, equivalent to callingevent.stopPropagation(). Stops the event from bubbling up to parent elements. -
.prevent
Prevents the default behavior of an event, equivalent to callingevent.preventDefault(). For example, prevents a form submission or link navigation. -
.capture
Uses event capturing mode instead of bubbling. The event is handled by the parent element before the target element. -
.self
Triggers the event handler only if the event target is the element itself, not its children. -
.once
Ensures the event handler is executed only once, then removed automatically. -
.passive
Improves scrolling performance for touch/wheel events by indicating that the handler won’t callpreventDefault(). Equivalent to{ passive: true }.