Considering issues such as reuse, when a form is split into multiple components, communication issues arise.
Two-way data binding cannot be used in this situation. I thought of the following method, but it is a bit complicated. I would like to ask for a good method.
The parent component passes a submit status value to the child component, and when the submit button is clicked, this value changes.
The subcomponent listens to the submit value through the onChange hook, and when it changes, the bound data inside the subcomponent is sent to the parent component through events.
The parent component listens to the event and gets the binding value of the child component. At this time, it integrates the data and sends the request.
If this situation already exists in some fields, an error value needs to be passed to the sub-component separately and displayed accordingly.
But it’s really troublesome, please ask for help...
我想大声告诉你2017-05-15 17:07:12
When it comes to the dimension of the form, the component particles are already small enough, so splitting them up is not asking for trouble. Only complex UIs need to be encapsulated, such as time selectors, color selectors, etc.