-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
$attrs missing property when used with v-model #8430
Comments
If you don't declare a prop, it will always be considered an attr, that's why it's there
offtopic: |
OK, so i need to change my code a bit :( But i have some more questions on this topic: I changed my example, to be more clear. The docs say the following: This is the case when i define the prop, but not when i do not define the prop. Why is there a difference ? What i want to do is to forward the v-model to a child component with a little as possible of code. |
v-model cannot create the prop for you on the child component. You must add a prop named |
So v-model does more than only mapping to v-bind and v-on :( |
no, that's the point, it only does that. And because it is done outside of the component, it cannot add a prop to the definition of the component it is used on |
Then i do not understand, why there is a difference in my first example "Without prop" |
…back to attrs if needed (issue vuejs#8430)
With this change, the behavior is exactely the same as with v-bind and v-on. |
reopening for visibility |
Yes, this could work, I think it makes it more consistent. |
… back to attrs if needed (fix vuejs#8430)
… back to attrs if needed (fix vuejs#8430)
This will make it easier to create a high order component. Before PR is accepted, we can use: {
computed: {
$attrsAll() {
return {
value: this.$vnode.data.model.value,
...this.$attrs
}
}
}
} |
fixed: b034abf |
Is there a way to fully bind v-model without having to emit events from the child component? I'm looking for a easy way to customize 3rd party components, perhaps with custom styles and/or default attributes. I'm currently binding Is there a more elegant way to achieve this, perhaps using extend? We can use scoped styles instead of the custom class. What about the default props/attributes? Thanks! |
Version
2.5.16
Reproduction link
https://codesandbox.io/s/106qozol1j
Steps to reproduce
In the component TestA the value is passed as prop => the key value is present in the $attrs variable
In the component TestB the value is passed as v-model => $attrs is empty
What is expected?
The key "value" should be present in $attrs variable
What is actually happening?
$attrs is empty
The text was updated successfully, but these errors were encountered: