mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 14:04:47 +08:00
Feat:copyRenderTree和copyNodeTree两个工具方法支持保留节点data和children以外的其他字段
This commit is contained in:
@@ -174,6 +174,12 @@ export const copyRenderTree = (tree, root, removeActiveState = false) => {
|
||||
tree.children[index] = copyRenderTree({}, item, removeActiveState)
|
||||
})
|
||||
}
|
||||
// data、children外的其他字段
|
||||
Object.keys(root).forEach((key) => {
|
||||
if (!['data', 'children'].includes(key) && !/^_/.test(key)) {
|
||||
tree[key] = root[key]
|
||||
}
|
||||
})
|
||||
return tree
|
||||
}
|
||||
|
||||
@@ -209,6 +215,12 @@ export const copyNodeTree = (
|
||||
tree.children[index] = copyNodeTree({}, item, removeActiveState, removeId)
|
||||
})
|
||||
}
|
||||
// data、children外的其他字段
|
||||
Object.keys(root).forEach((key) => {
|
||||
if (!['data', 'children'].includes(key) && !/^_/.test(key)) {
|
||||
tree[key] = root[key]
|
||||
}
|
||||
})
|
||||
return tree
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user