Feat:copyRenderTree和copyNodeTree两个工具方法支持保留节点data和children以外的其他字段
This commit is contained in:
parent
d85210372d
commit
11c6fa3e45
@ -174,6 +174,12 @@ export const copyRenderTree = (tree, root, removeActiveState = false) => {
|
|||||||
tree.children[index] = copyRenderTree({}, item, removeActiveState)
|
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
|
return tree
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +215,12 @@ export const copyNodeTree = (
|
|||||||
tree.children[index] = copyNodeTree({}, item, removeActiveState, removeId)
|
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
|
return tree
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user