Sons assembly Vue each v-model communication

First, it is clear what is the parent component, subassembly

Parent component: Contains the imported subassemblies file as a tab to call subcomponents
subcomponents: write specific style or logical file

Then the communication module Sons

Sons principle component vue communication is unidirectional data flow

Parent => child is passed through the props in the form of the sub-component parameters, sub-assemblies props in the property can not be modified in the sub-assembly, otherwise vue will complain,
child => Parent emit through the form, based on the child component triggers an event , to a one-way transmission method corresponding to the parent element.

Existing business need to put a date interval assembly, comprising two date control. The most basic, we need to pass parameters to the component two dates startDate and endDate, sub-assemblies receive these two parameters are assigned to two controls, so the parent component to form the startDate props and endDate incoming sub-assembly, but the problem is caused by such modifications subassembly date controls and does not modify the parent component startDate and endDate!

One way is to create a sub-assemblies in two internal data attribute, start and end, and when initializing assign it to startDate and endDate (no error), then call handleDatechange parent component when @ change the start or end to pass the parent component, this would resolve the component parameters passed his son!

Note: startDate and endDate are string type, object type not tried.

Guess you like

Origin www.cnblogs.com/bestrack/p/11469459.html
Recommended