-
Notifications
You must be signed in to change notification settings - Fork 544
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
Component v-model API change #31
Conversation
Having an additional attribute for custom elements to support native-like behaviour for v-model is kind of strange. I would love to see v-model support an extra argument for that case with a special symbol, for example:
|
@CyberAP I also thought about that, but a modifier woud make more sense instead of |
It would be nice if |
Why
Instead of
|
This will be breaking a lot of packages which implement v-model on custom components.
Why not leave the model option for the first few 3.x versions, deprecate it so that the upgrade path will be easier for existing Vue 2.x packages ? |
@edcoreweb i think such option removals must happen in major version bumps like 2->3 or 3->4. If you don't remove it in 3.0.0, you will not be able to remove it until 4.0.0. |
wouldnt it be better to name the default model value prop |
This is much better. |
This RFC is now in final comments stage. An RFC in final comments stage means that: The core team has reviewed the feedback and reached consensus about the general direction of the RFC and believe that this RFC is a worthwhile addition to the framework. |
Co-Authored-By: Jacek Karczmarczyk <jkarczm@gmail.com>
Regarding |
I believe the model is `text`, not `foo`, in `v-model.foo.bar="text"`
@sqal yeah, good catch! We need to generate different prop for Update: fixed in vuejs/core@f178874 |
Why is it not possible to write model handler in render function with modifiers? Or at least define it as an object? h('Foo', {
'onUpdate:bar': {
handler: val => (baz = val),
trim: true,
}
}) |
I think, writing |
@CyberAP @denisinvader the format is optimized for the consuming component and the compiler. For manual render functions you can always build a little helper to make the usage read nicer: withModel(h(SomeComp), {
prop: 'foo', // optional
value: foo,
update: value => (foo = value),
modifiers: { trim: true }
}) @denisinvader Vue will have its own JSX transform which gives us the ability to handle the transform for you. The 2.x transform only handles |
我们可以用 |
Adjust
v-model
API when used on custom components.This builds on top of #8 (Replace
v-bind
's.sync
with av-model
argument).Rendered