Update index.ts (#2336)

fix(deepMerge): 原对象受浅拷贝影响的问题
This commit is contained in:
ludens blunt 2022-11-08 09:06:24 +08:00 committed by GitHub
parent 7dcb38cac6
commit df0e0cbe69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import type { App, Plugin } from 'vue';
import { unref } from 'vue';
import { isObject } from '/@/utils/is';
import { cloneDeep } from 'lodash-es';
export const noop = () => {};
@ -35,10 +36,11 @@ export function setObjToUrlParams(baseUrl: string, obj: any): string {
// 深度合并
export function deepMerge<T = any>(src: any = {}, target: any = {}): T {
let key: string;
const res: any = cloneDeep(src)
for (key in target) {
src[key] = isObject(src[key]) ? deepMerge(src[key], target[key]) : (src[key] = target[key]);
res[key] = isObject(res[key]) ? deepMerge(res[key], target[key]) : (res[key] = target[key]);
}
return src;
return res;
}
export function openWindow(