vue2 modifiers

When browsing the article, I suddenly saw the wording of v-model.trim. I was suddenly interested, and I checked it out, and then found that there are some other modifiers, which are very practical in daily life. I am here to record the official link .

.trim

To automatically filter the leading and trailing blank characters entered by the user , you can add a trim modifier to v-model:

<input v-model.trim="msg">

.lazy

By default, v-model synchronizes the value of the input box with the data after each input event is triggered. Add the lazy modifier to switch to synchronous after the change event.
The above sentence is turned into vernacular: the change event is triggered after the input box loses focus.

<input v-model.lazy="msg">

.number

To automatically convert the user's input value into a numeric type, you can add a number modifier to v-model:

<input v-model.number="age" type="number">

Note: v-model.number has character length limit, length<11

Guess you like

Origin blog.csdn.net/qq_46566911/article/details/121784467