How can you achieve two-way data binding on a custom component in Vue.js?

Instruction: Describe the process of implementing two-way data binding on a custom Vue.js component.

Context: This question examines the candidate's ability to extend Vue.js's core functionality, specifically their skill in enabling two-way data binding on components they've created, showcasing their mastery of Vue.js's reactive data flow.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

In Vue 3, the default component v-model contract is a modelValue prop and an update:modelValue event. The child renders the input value and emits a requested change; the parent owns the actual state. Vue 2's value/input convention is different.

This complete Vue 3 child SFC implements the explicit contract without requiring defineModel:...

Related Questions