合同小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
492 B

  1. // @ts-nocheck
  2. /**
  3. *
  4. * @param obj
  5. * @returns
  6. */
  7. export function cloneDeep<T>(obj: any): T {
  8. // 如果传入的对象是基本数据类型(如字符串、数字等),则直接返回
  9. // if(['number', 'string'].includes(typeof obj) || Array.isArray(obj)){
  10. // return obj as T
  11. // }
  12. if(typeof obj == 'object'){
  13. return JSON.parse(JSON.stringify(obj as T)) as T;
  14. }
  15. return obj as T
  16. }