-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
One way data binding updating parent from child #6585
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
Comments
I don't know what's happen, how can component update value ouside without $emit ? |
I think this jsfiddle implementation is against the pattern. TL;DR; object or an array must not be updated in a child component. As you see in this, if the value is re-assigned, you will seen a warning. https://jsfiddle.net/ecgxykrt/2/
To make parent props change to be reflected to child components, I think Vue must keep its own address of a variable(I might be wrong on this). If Vue extend the variable, Vue also watch the change of parent value, which is not ideal. It would be fantastic to find a way to avoid the deep-level object manipulation, but I don't think it's possible in any language without another performance cost. |
^ what @allenhwkim said. This has also been explicitly raised as a warning in docs. |
Version
2.4.2
Reproduction link
https://jsfiddle.net/ecgxykrt/
Steps to reproduce
What is expected?
The App component's dataTest could not be updated.
What is actually happening?
The App component's dataTest is being updated.
The text was updated successfully, but these errors were encountered: