Complete the code to bind the custom model value using v-model.
<template> <input type="text" v-model=[1] /> </template> <script setup> const props = defineProps({ modelValue: String }) </script>
The v-model directive by default binds to the modelValue prop in Vue 3 custom components.
Complete the code to emit the update event for the custom v-model.
<script setup>
const emit = defineEmits([[1]])
</script>Vue 3 custom v-model uses the event name update:modelValue to update the parent component.
Fix the error in emitting the update event with the new value.
<script setup> const emit = defineEmits(["update:modelValue"]) function onInput(event) { emit([1], event.target.value) } </script>
The event emitted to update the v-model must be exactly update:modelValue.
Fill both blanks to customize v-model with a different prop and event name.
<script setup>
const props = defineProps({
[1]: String
})
const emit = defineEmits([[2]])
</script>To customize v-model, you define a different prop and matching update event name.
Fill all three blanks to implement a custom v-model with a checkbox input.
<template> <input type="checkbox" :checked=[1] @change="event => emit([2], event.target.checked)" /> </template> <script setup> const props = defineProps({ [3]: Boolean }) const emit = defineEmits(["update:isChecked"]) </script>
The prop and event names must match for the custom v-model to work. The checkbox's checked state binds to the prop.