UNPKG

china-admin-area

Version:

中华人民共和国行政区域数据,适配element-ui antd级联组件

33 lines (32 loc) 776 B
'use strict'; function deepClone(target) { // 对于数字、字符串、布尔 if (typeof target !== 'object') { return target; } // 对于Date if (target instanceof Date) { return new Date(target); } // 对于数组 if (target instanceof Array) { const clone = []; for (let i = 0, len = target.length; i < len; i++) { clone[i] = deepClone(target[i]); } return clone; } // 对于Object对象 if (target instanceof Object) { const clone = {}; for (const key in target) { if (target.hasOwnProperty(key)) { clone[key] = deepClone(target[key]); } } return clone; } } module.exports = { deepClone }