选择两个组件调用toComponent 收藏起来 清空画布 方便测试 拖拽收藏的组件到画布 在拖拽一次到画布 现在画布有两个一样的收藏组件 然后全选 再调用 toComponent 生成的新的组件 拖拽到画布后 不显示组件
// toComponent 生成的新的组件
[
{
"id": "e633899",
"name": "combine",
"x": 44.5,
"y": 83.5,
"ex": 520.5,
"ey": 204.5,
"width": 476,
"height": 121,
"center": {
"x": 282.5,
"y": 144
},
"children": [
"fb35658",
"669def0"
]
},
{
"id": "fb35658",
"name": "combine",
"x": 0,
"y": 0.24793388429752067,
"ex": 0.7331932773109243,
"ey": 1,
"width": 0.7331932773109243,
"height": 0.7520661157024794,
"center": {
"x": 454.5,
"y": 192.5
},
"children": [
"7c352c28",
"1631dd95"
],
"parentId": "e633899",
"lineWidth": 1,
"fontSize": 12,
"lineHeight": 1.5,
"anchors": [],
"rotate": 0,
"locked": 2
},
{
"id": "669def0",
"name": "combine",
"x": 0.2668067226890756,
"y": 0,
"ex": 1,
"ey": 0.7520661157024794,
"width": 0.7331932773109243,
"height": 0.7520661157024794,
"center": {
"x": 454.5,
"y": 192.5
},
"children": [
"20a03fd",
"0991647"
],
"parentId": "e633899",
"lineWidth": 1,
"fontSize": 12,
"lineHeight": 1.5,
"anchors": [],
"rotate": 0,
"locked": 2
}
]
//拖拽到画布后 新组件的子组件的children为空
const onDragStart = (e, data) => {
e.dataTransfer.setData('Topology', JSON.stringify(deepClone(data)))
}