What are event modifiers?
Event modifiers are special suffixes (for example: .stop, .prevent, .once) that are added to the v-on directive and let you change an event's behavior without writing extra JavaScript code.
In simpler terms:
Event modifiers are a way to tell Vue exactly how to handle an event, automatically performing commonly used
event.*actions.
They exist for convenience, template cleanliness, and reducing the amount of boilerplate code.
What do event modifiers look like?
<button @click.stop="doSomething"></button>
<button @submit.prevent="onSubmit"></button>
<input @keyup.enter="search">Why are modifiers needed?
They let you:
- stop propagation (
stopPropagation) - cancel default behavior (
preventDefault) - make a handler fire only once
- listen to events only on the element itself
- work with keys
- improve performance (passive)
And all this without writing extra code:
<button @click="event.stopPropagation(); event.preventDefault(); doStuff()">...</button>becomes:
<button @click.stop.prevent="doStuff">The main event modifiers
1. .stop
Stops the event from propagating.
@click.stopEquivalent to:
event.stopPropagation()2. .prevent
Cancels the browser's default behavior.
@submit.preventEquivalent to:
event.preventDefault()3. .once
The handler fires only once.
@click.onceAfter the first call, Vue removes the listener itself.
4. .self
Fires only if the event came from the element itself, not from its children.
@click.self5. .capture
Listens to the event during the capture phase (before propagation).
@click.capture6. .passive
Creates a passive listener, useful for scroll handlers.
@scroll.passiveImproves performance.
Key modifiers
Applied to keyup / keydown:
@keyup.enter
@keyup.esc
@keyup.space
@keyup.up
@keyup.ctrl.enterThis also counts as an event modifier.
Combining modifiers
You can combine them:
@click.stop.prevent.once="save"Order matters: Vue generates the handler in the order the modifiers are written.
Where can't you use modifiers?
- Inside components for arbitrary custom events (they only work with DOM events and system events)
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.