Skip to content
Discussion options

You must be logged in to vote

Hi there!

In Vue, you cannot programmatically check if an event modifier (like .prevent or .stop) was used from within the event handler or the component itself.

Why is this the case?

Event modifiers in Vue are compiler-level syntactic sugar. When you write @click.prevent="handler", the Vue compiler transforms this template into a wrapper function that automatically calls event.preventDefault() before executing your handler.

Because the modifier is applied by the parent component at compile time, the child component (or the handler function) receives the event after the wrapper has already processed it. There is no internal flag or metadata passed along with the event to indicate which mo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Blue101black
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants