From ce7cb2f17facfb27f5ebd81591defce1beda0459 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: Mon, 18 Feb 2019 13:06:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8Object.assign()=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index 821392e9..33383258 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -276,14 +276,7 @@ export function deepClone(source) { if (!source && typeof source !== 'object') { throw new Error('error arguments', 'shallowClone') } - 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] - } - }) + const targetObj = source.constructor === Array ? Object.assign([], source) : Object.assign({}, source) return targetObj }