vue his son rendering components

Problem Description: parent component called a sub-assembly, passed an id attribute to the sub-components,

However, the id attribute of the props in the subassembly assigned to another property defined inside myId data, and write a listening watch the id of the props.

Results: The first time is not updated interface subassembly (i.e., data attributes are not updated inside myId); second and later on may be the

Reason: The value for the first time to pass through and not assigned to a myId, leading to the interface is not updated, as long as mounted inside an assignment once.

 

 

 

In fact, sub-assemblies and parent components together before mounted on the DOM has been rendered to the page, but after the operation of the parent component sub-assemblies produced new value will also updated in real time

(In fact, his son is the equivalent components on the same principle components inside, because the distinction between father and son just to develop a simple assembly, but only after the fact to render a page).

If direct props in the sub-component properties name rendered in the page, not to the first assignment in mounted inside, do not watch the monitor inside the change props;

However, if the props assigned to each sub-component itself in a data sub-assemblies inside, we need to first assignment (only for the first time) in mounted inside,

And props need to monitor changes in the watch inside and reassigned (after the first will enter to watch, that is, after the page lifecycle will be mounted DOM rendering is complete, will enter wacth this method)!

 

Guess you like

Origin www.cnblogs.com/ajaxlu/p/11433254.html