press-ui
Version:
简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目
25 lines (19 loc) • 505 B
JavaScript
import { isObject, isDef } from '../utils/validator';
function assignKey(to, from, key) {
const val = from[key];
if (!isDef(val)) {
return;
}
if (!hasOwnProperty.call(to, key) || !isObject(val)) {
to[key] = val;
} else {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
to[key] = deepAssign(Object(to[key]), from[key]);
}
}
export function deepAssign(to, from) {
Object.keys(from).forEach((key) => {
assignKey(to, from, key);
});
return to;
}