What is v-model?
The v-model directive creates two-way data binding between form inputs and Vue data.
Basic Syntax
HTMLRead-only
1
Text Input Example
HTMLRead-only
1
Checkbox Binding
HTMLRead-only
1
Radio Button Binding
HTMLRead-only
1
Select Dropdown
HTMLRead-only
1
Modifiers
| Modifier | Description |
|---|---|
| .lazy | Updates on change event instead of input |
| .number | Converts input to number |
| .trim | Trims whitespace |
Modifiers Example
HTMLRead-only
1
Best Practices
- Use v-model for form inputs only
- Keep data reactive and simple
- Use modifiers when needed
- Avoid overusing two-way binding
Common Mistakes
- Using v-model on non-form elements
- Ignoring modifiers for data types
- Overusing two-way binding unnecessarily
- Mixing v-model with manual event handling incorrectly
Conclusion
The v-model directive simplifies form handling in Vue by providing seamless two-way data binding between inputs and data.