未验证 提交 df0e0cbe 编写于 作者: blunt_z's avatar blunt_z 提交者: GitHub

Update index.ts (#2336)

fix(deepMerge): 原对象受浅拷贝影响的问题
上级 7dcb38ca
......@@ -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(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册