From 3519d3beecc3ed06cc9036d7ca9510071c9b6a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=E5=93=A5?= <12271764+darrenteng@user.noreply.gitee.com> Date: Sun, 9 Mar 2025 05:58:46 +0000 Subject: [PATCH] =?UTF-8?q?update=20ruoyi-ui/src/utils/ruoyi.js.=20//=20?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E5=85=83=E7=B4=A0=E6=98=AF=E5=90=A6=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E6=9C=89=20children=20=E5=AD=97=E6=AE=B5=EF=BC=8C?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E5=88=99=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20children=20=E7=A9=BA=E6=95=B0=E7=BB=84=E5=AD=97=E6=AE=B5=20?= =?UTF-8?q?=20=20=20=20//=20=E9=81=BF=E5=85=8D=E5=90=8E=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=B8=AD=20parentObj[config.childrenList]=20?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=20undefined=20=E7=9A=84=E6=83=85=E5=86=B5=20?= =?UTF-8?q?=20=20=20=20//=20=E7=94=9A=E8=87=B3=E8=BF=9B=E8=80=8C=E5=BC=95?= =?UTF-8?q?=E5=8F=91=20[Vue=20warn]:=20Duplicate=20keys=20detected:=20'136?= =?UTF-8?q?6'.=20This=20may=20cause=20an=20update=20error.=20=E7=B1=BB?= =?UTF-8?q?=E4=BC=BC=E7=9A=84=E8=AD=A6=E5=91=8A=20=20=20=20=20if=20(!d[con?= =?UTF-8?q?fig.childrenList])=20{=20=20=20=20=20=20=20d[config.childrenLis?= =?UTF-8?q?t]=20=3D=20[];=20=20=20=20=20}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: D哥 <12271764+darrenteng@user.noreply.gitee.com> --- ruoyi-ui/src/utils/ruoyi.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 8ad1e89c..aab303c7 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -167,6 +167,12 @@ export function handleTree(data, id, parentId, children) { for (let d of data) { let id = d[config.id]; childrenListMap[id] = d; + // 检查元素是否已经有 children 字段,如果没有则添加 children 空数组字段 + // 避免后面的代码中 parentObj[config.childrenList] 出现 undefined 的情况 + // 甚至进而引发 [Vue warn]: Duplicate keys detected: '1366'. This may cause an update error. 类似的警告 + if (!d[config.childrenList]) { + d[config.childrenList] = []; + } } for (let d of data) {