/**
* 深拷贝
*/
export function deepClone(val: any): any {
if (Object.prototype.toString.call(val) === '[object Object]') {
const obj: any = {}
for (const key in val) {
obj[key] = deepClone(val[key])
}
return obj
} else if (Array.isArray(val)) {
return val.map(item => deepClone(item))
} else {
return val
}
}
网友评论