defineModel()
is a new feature introduced in Vue 3.4+. The official documentation provides the following example:
const model = defineModel()
model.value = 'hello'
Initially, it appears that model
is an object with a value
property.
However, there is another example provided later on:
const [modelValue, modelModifiers] = defineModel()
This case introduces some confusion as it seems like the result of defineModel()
is actually an array containing modelValue
and modelModifiers
.
I am trying to make sense of these examples, but it seems like there is some sort of "magic" happening behind the scenes. Can anyone offer further explanation or insights? Thank you.