diff --git a/src/utils/geek.ts b/src/utils/geek.ts index f164832..6e72dc0 100644 --- a/src/utils/geek.ts +++ b/src/utils/geek.ts @@ -146,4 +146,21 @@ export function deepClone(obj: any) { result[key] = deepClone(value); } return result; +} + +/** + * 深度复制 + * @param obj 待复制的对象 + * @param result 要复制到的对象 + * @returns 复制的对象 + */ +export function deepCloneTo(obj: T,result:T) { + if (obj == null || typeof obj !== 'object') { + return obj; + } + for (let [key, value] of Object.entries(obj)) { + // @ts-ignore + result[key] = deepClone(value); + } + return result; } \ No newline at end of file