Closed
Description
In this comment Evan pointed out to me that vModelText
(and friends) is exported for the compiler only and is not public nor documented.
Unless I miss something, this has an unfortunate consequence: you can't write a JS render function that binds v-model
of an input.
Because this template:
<input v-model="name">
is compiled into the JS equivalent of this by the compiler:
<input v-model-text="name" @update:modelValue="name = $event">
and you can't do that transformation in user code if v-model-text
is off-limits.
Alternatives
-
Use undocumented apis 🤞
Drawback: risks breaking at any minor release. -
Re-implement v-model yourself by compiling
<input :value="name" @input="name = $event.target.value">
Drawback: this is not trivial when implementing more complex features, such as modifiers v-model.trim
, or other models e.g. v-model-checkbox
with an array.
- Create a micro-component with compiler and re-use it in your render function.:
<input v-model="$props.name" v-bind="$attrs">
Drawback: far from pretty.
Metadata
Metadata
Assignees
Labels
No labels