Subscribe on changes!

Thread v-model as directive also when used with Component

avatar
Nov 28th 2021

What problem does this feature solve?

v-model directive used with component is not available for other directives (by vnode.dirs) like it is possible with native input. Even when the directive is invisible, I would at least expect access to the modelValue property inside vnode.props.

I'm playing with "template-driven" form validation and it hard to cooperate with v-model when you can combine it only with simple expressions (we can't pass function or scoped slot prop here)

What does the proposed API look like?

Create a new variant of v-model like V_MODEL_COMPONENT just to make it available to other directives.

avatar
Nov 28th 2021

You can read about how to handle this at https://v3.vuejs.org/guide/component-custom-events.html#multiple-v-model-bindings. You might also want to lookup inheritAttrs for custom form elements.


Please, next time consider using the forum, the Discord server or StackOverflow for questions first. But feel free to come back and open an issue if it turns out to be a bug 🙂

avatar
Nov 28th 2021

@posva This, unfortunately, has nothing to do with it.

Check my example and log from my directive (for vnode): template directive As you see, for my component "Input" there is no info about v-model directive and even custom prop "disabled" (I even consider it as issue)