From a4f6006efd19a202ba3e2209e4ca552de0d16aa4 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Wed, 27 Sep 2023 11:02:37 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8DisSameObject?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=96=B9=E6=B3=95=E9=80=BB=E8=BE=91=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= 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, 10 insertions(+), 2 deletions(-) diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index 28b90333..fbd16515 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -841,8 +841,12 @@ export const isSameObject = (a, b) => { // b没有a的一个字段,那么肯定不相同 if (!keysb.includes(key)) return false // 字段名称一样,那么需要递归判断它们的值 - return isSameObject(a[key], b[key]) + const isSame = isSameObject(a[key], b[key]) + if (!isSame) { + return false + } } + return true } else if (type === 'Array') { // 如果都是数组 // 数组长度不一样,肯定不相同 @@ -854,8 +858,12 @@ export const isSameObject = (a, b) => { const typea = getType(itema) const typeb = getType(itemb) if (typea !== typeb) return false - return isSameObject(itema, itemb) + const isSame = isSameObject(itema, itemb) + if (!isSame) { + return false + } } + return true } else { // 其他类型,直接全等判断 return a === b