What are the commonly used modifiers in vue?

Common modifiers

(1) trim: filter leading and trailing spaces

<input v-model.trim='name'>

(2) number: automatically converted to number type

<input v-model.number='name'>

(3) Lazy: Synchronize the value with the data.
By default, v-model synchronizes the value of the input box with the data after each input event is triggered. You can add the lazy modifier to change to use the change event for synchronization:

<!-- 在“change”时而非“input”时更新 -->
<input v-model.lazy="name" >

Event modifier

E.g:

<button v-on:click.stop="btn"></button >
//缩写
<button @click.stop="btn"></button >

(1) stop: prevent the click event from bubbling
(2) prevent: intercept the default event
(3) passive: do not intercept the default event
(4) capture: event capture mode. That is, the event triggered by the element itself is processed here first, and then handed over to the internal element for processing

Key modifier

E.g:

<input v-on:keyup.enter="name"> 
//缩写
<input @keyup.enter="submit">

(1) enter: enter
(2) tab: switch
(3) delete (capture "delete" and "backspace" keys)
(4) esc: exit
(5) space: space

Guess you like

Origin blog.csdn.net/qq_44469200/article/details/112985141