Vue 3 v-model Directive
v-model The directive is used to create two-way data binding on form input elements and components.
Basic Explanation
v-model The directive creates two-way data binding on form elements and components. It automatically selects the correct method to update the element based on the control type.
- Expected type: varies by form element type
- Purpose: creates two-way data binding on form input elements and components.
Basic Usage
1. Text Input
Example
Entered content: {{ message }}
2. Checkbox
Example
Agreed: {{ agreed }}
Modifiers
- .lazy: syncs after the change event (rather than input)
- .number: automatically converts to a number
- .trim: automatically strips leading and trailing whitespace
Vue 3 Built-in Directives