Custom Clone
We can pass a function through the clone attribute to customize the cloned node, and JSON.parse(JSON.stringify()) is used internally to implement cloning. You can also choose to use lodash or other third-party libraries. Clone, this function is commonly used in low-code scenarios, such as dragging form elements to the canvas, and a new component element needs to be cloned.
When we use this function, we need to pay attention to:
- The
pullattribute in thegroupattribute of the cloned component must beclone, otherwise it cannot be cloned. - The
nameattribute in thegroupof the cloned component must be consistent with thenameattribute in thegroupof the cloned component, otherwise it cannot be cloned.
TIP
Note: When we use the clone attribute, we need to regenerate a unique key, otherwise it will cause the component to render abnormally.