1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-09-10 07:23:22 +08:00

Merge 3bed61fd073d9e4374db2ae79044dbb8cd90b052 into 700e08b7951e9b6947ec0521af93354280776b2e

This commit is contained in:
Serge Gao 2018-01-22 02:35:34 +00:00 committed by GitHub
commit 42fba5fc87

View File

@ -249,19 +249,6 @@ export function debounce(func, wait, immediate) {
}
export function deepClone(source) {
if (!source && typeof source !== 'object') {
throw new Error('error arguments', 'shallowClone')
}
const targetObj = source.constructor === Array ? [] : {}
for (const keys in source) {
if (source.hasOwnProperty(keys)) {
if (source[keys] && typeof source[keys] === 'object') {
targetObj[keys] = source[keys].constructor === Array ? [] : {}
targetObj[keys] = deepClone(source[keys])
} else {
targetObj[keys] = source[keys]
}
}
}
let targetObj = JSON.parse(JSON.stringify(source));
return targetObj
}