Performance: v-model for two-way binding
This affects how quickly user input updates the UI and how efficiently data changes propagate between components.
<input v-model="userInput" /><input :value="userInput" @input="userInput = $event.target.value" />
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual input binding with :value and @input | Multiple event listeners | Multiple reflows on each input | Higher paint cost due to frequent updates | [X] Bad |
| Using v-model for two-way binding | Single reactive binding | Minimal reflows, batched updates | Lower paint cost with optimized updates | [OK] Good |
v-model in Vue?v-model doesv-model connects form inputs to data so changes in one update the other automatically.name using v-model?v-model="propertyName" without colon or extra suffix.data() { return { message: 'Hello' } }
<input v-model="message" />
<p>{{ message }}</p>message data property immediately.message, which changes to "Hi" after typing.<input v-model="userName">
userName is defined in data, why might this cause an error?<input /> or have a closing tag.isChecked using v-model. Which code snippet correctly implements this with two-way binding and shows "Checked" or "Not checked" text accordingly?v-model="isChecked" binds the checkbox state two-way with the data property.isChecked.{{ isChecked ? 'Checked' : 'Not checked' }}
[OK]Pass the test and this pattern moves unknown