Files
iot-device-management-frontend/apps/web-ele/src/utils/bean.ts

18 lines
567 B
TypeScript
Raw Normal View History

/**
* target: {a:1} source:{a:2,b:3} {a:2}
* @param target
* @param source
*/
export const copyValueToTarget = (target: any, source: any) => {
const newObj = Object.assign({}, target, source);
// 删除多余属性
Object.keys(newObj).forEach((key) => {
// 如果不是target中的属性则删除
if (Object.keys(target).indexOf(key) === -1) {
delete newObj[key];
}
});
// 更新目标对象值
Object.assign(target, newObj);
};