js 深拷贝
// 深拷贝
export function deepClone(source) {
if (typeof source !== "object" || source == null) {
return source;
}
const target = Array.isArray(source) ? [] : {};
for (const key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
if (typeof source[key] === "object" && source[key] !== null) {
target[key] = this.deepClone(source[key]);
} else {
target[key] = source[key];
}
}
}
return target;
},
}