mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-09-08 03:01:56 +08:00
用Object.assign()复制数组对象
This commit is contained in:
parent
6c8fda9244
commit
ce7cb2f17f
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user