Two-way binding 13 / 42
This two-way data binding is so common that Vue has an abstraction for it called v-model
. It behaves exactly like in the previous chapter.
v-model
works with any type of input (checkbox, radio, etc.) as well as <select>
and <textarea>
.
Try adding the modifier .lazy
to listen to the change event instead of the input event: v-model.lazy="name"
.
Other modifiers are .trim
to trim the value and .number
to cast it to a number.