Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute inheritance does not support v-model #2667

Closed
Korijn opened this issue Nov 24, 2020 · 3 comments
Closed

Attribute inheritance does not support v-model #2667

Korijn opened this issue Nov 24, 2020 · 3 comments

Comments

@Korijn
Copy link

Korijn commented Nov 24, 2020

Version

3.0.2

Reproduction link

https://jsfiddle.net/kr16gc2s/1/

Steps to reproduce

Try and adjust the slider; you won't see the text update.

What is expected?

The text should update upon adjusting the slider.

What is actually happening?

It doesn't update.

@posva
Copy link
Member

posva commented Nov 24, 2020

See #1989

You still need to pass the correct attributes and event listeners based on your inner component that receives the v-model. In your case, add a prop modelValue, bind it with :value="modelValue" and add the emit @change="$emit('modelValue:update', $event.target.value)

Otherwise, this would mean applying a magic conversion for a prop named modelValue and onUpdate:modelValue but also any customized name

@posva posva closed this as completed Nov 24, 2020
@Korijn
Copy link
Author

Korijn commented Nov 24, 2020

Thanks for the workaround.

You've phrased it differently but essentially you are saying "indeed, wrapping inputs with attribute inheritance does not support v-model, unless you explicitly add support for it to the wrapping component (see example)", is that correct?

Would it be helpful if I open a PR to add this to the documentation? It's a pretty nasty gotcha.

@posva
Copy link
Member

posva commented Nov 24, 2020

If you find a way to naturally introduce it (not a note/tip that breaks the flow), at https://v3.vuejs.org/guide/component-basics.html#using-v-model-on-components or somewhere else, I'm sure the docs team will appreciate! The idea is said there, though, v-model becomes an attribute an event listener, it's a convention.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants