The concept of v-model
in Vue is straightforward.
Specify a responsive message
(normally a ref), and after that bind this worth to an input utilizing v-model=" message"
This produces a two-way information circulation:
- Customer kinds right into the input:
message
ref adjustments (initial circulation) message
ref adjustments programmaticaly: the worth of the input adjustments (2nd circulation)
Allow’s see just how to utilize v-model
to bind type inputs in Vue 3.
1. Binding a kind input
Allow’s apply an element that makes an input area with the preliminary worth ' Unidentified'
The worth that customer presents right into the input area makes on the display.
v-model
fits perfectly to apply such an element. Attaching v-model
with the input area needs 2 straightforward actions:
const message = ref()
: responsive worth to act as a information bus forv-model
v-model=" message"
: includev-model
to the input area tag appointed withmessage
vue
< import { ref
} from' vue' const message =
ref ( ' Unidentified' ) // Action 1: produce information bus<<<