Skip to content

Conversation

dmfilipenko
Copy link

#297:fix extend current data if exist

@dmfilipenko dmfilipenko changed the title fix: #297 extend current data if exist extend current data if exist Jun 10, 2014
@dlh
Copy link

dlh commented Jun 10, 2014

This will cause the data shared between the parent and child vm to become out of sync.

For example, in the child if a property is changed then that change is not reflected in the parent. See this example, which would fail with your changes applied.

@dmfilipenko
Copy link
Author

@dlh i don't see any problem in showen example, can you please provide more specific case?

@dlh
Copy link

dlh commented Jun 10, 2014

The linked example uses Vue 0.10.5. You need to run it with your modified version to see the problem.

@yyx990803
Copy link
Member

As @dlh pointed out, v-with links the parent object and the child's $data by reference, so they are sharing the same object. Extending a new copy makes the two out of sync. I'd say the overwriting is expected behavior in this case.

@dmfilipenko
Copy link
Author

So, what is the best way to create the components with predefined values? how I understand, now it is impossible?

@yyx990803
Copy link
Member

You can either do multiple clause v-with to bind individual values from parent, or set values in your child component's ready hook.

@yyx990803 yyx990803 closed this Jun 19, 2014
@dmfilipenko dmfilipenko deleted the dev branch June 19, 2014 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants