Common event modifiers in Vue are: .stop/.prevent: prevent the default operation. .capture: Capture the event and handle it before bubbling. .self: Fires the handler only on the event target. .once: Remove the handler after triggering once. .passive: Improves performance and does not block default operations. .enter: The handler is only triggered when the enter key is pressed.
Common event modifiers in Vue
Event modifiers are used in Vue on event handlers Special suffixes that add extra functionality. By using modifiers, you can modify the behavior of an event handler, such as preventing the default action, preventing the event from bubbling, or triggering the event only under certain conditions.
Common event modifiers include:
.stop
, but compatible with all browsers. Example:
<code class="html"><button v-on:click.prevent="doSomething">点我</button></code>
In this example, the .prevent
modifier is used to prevent the default browser form submission action.
Usage Guide:
When using event modifiers, you should pay attention to the following points:
.stop.prevent
. .once()
. The above is the detailed content of Common event modifiers in vue. For more information, please follow other related articles on the PHP Chinese website!