From 11c6fa3e4536746e897e5adb480ab4f8c3b0eaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Wed, 25 Dec 2024 09:57:04 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9AcopyRenderTree=E5=92=8CcopyNodeTre?= =?UTF-8?q?e=E4=B8=A4=E4=B8=AA=E5=B7=A5=E5=85=B7=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BF=9D=E7=95=99=E8=8A=82=E7=82=B9data?= =?UTF-8?q?=E5=92=8Cchildren=E4=BB=A5=E5=A4=96=E7=9A=84=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/utils/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index 473767a0..b96cc128 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -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 }