From 3cb86f446b646c05bb621c92c36af5de9822f706 Mon Sep 17 00:00:00 2001 From: D <3066417822@qq.com> Date: Mon, 28 Aug 2023 18:21:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/geek.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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