Event modifiers in Vue modify its behavior by appending modifiers after the event handler name. Common modifiers include: .stop: prevents the event from bubbling. prevent: prevents the event from default behavior.capture: captures Stage processing event.self: Triggered only when the event target is the element itself.once: Triggered only when the event is triggered for the first time.passive: Improve scroll and touch event performance
The role of event modifiers in Vue
Event modifiers are a special syntax in Vue that are used to modify the behavior of event handlers. They are used by appending one or more modifiers to the event handler function name.
Common event modifiers include:
<a>
tag). Example:
<code class="html"><button @click.prevent="handleClick">点击按钮</button></code>
In the above example, the .prevent
modifier is used to prevent the page from refreshing when the button is clicked.
Other examples:
@click.stop
@click.capture
@click.self
@click.once
@scroll.passive
The above is the detailed content of What can event modifiers do in vue. For more information, please follow other related articles on the PHP Chinese website!