/** * 深度复制 * @param {*} from 源对象 * @param {*} to 目标对象 */ export function objectCopy (from, to) { if (from === null) { return null } if (to) { for (const i in to) { if (from[i] || typeof from[i] !== 'undefined') { to[i] = typeof from[i] === 'object' ? objectCopy(from[i]) : from[i] } } } else { to = from instanceof Array ? [] : {} for (const i in from) { to[i] = typeof from[i] === 'object' ? objectCopy(from[i]) : from[i] } } return to }