From 90d9890b069a2d91073543f55797e0d694ea13fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=BA=91=E6=B5=B7=20mayunhai=20=28=29?= Date: Fri, 1 Mar 2019 09:47:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/index.js b/src/utils/index.js index 22456861..613ae2a3 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -276,7 +276,14 @@ export function deepClone(source) { if (!source && typeof source !== 'object') { throw new Error('error arguments', 'shallowClone') } - const targetObj = source.constructor === Array ? Object.assign([], source) : Object.assign({}, source) + const targetObj = source.constructor === Array ? [] : {} + Object.keys(source).forEach(keys => { + if (source[keys] && typeof source[keys] === 'object') { + targetObj[keys] = deepClone(source[keys]) + } else { + targetObj[keys] = source[keys] + } + }) return targetObj }