场景1、将一个对象的部分字段值赋值给另一个对象
场景2、全部字段赋值
editPorductParams = {
'id': '',
'cashSettlePrice': '',
'monthSettlePrice': '',
'unassemblePurchaseMonthSettlePrice': '',
'assemblePurchaseMonthSettlePrice': '',
'unassemblePurchaseCashSettlePrice': '',
'assemblePurchaseCashSettlePrice': '',
'referencePrice': '',
'referenceLink': '',
'timeliness': '',
'remark': ''
}
resObj = {
'id': '',
'cashSettlePrice': '',
'monthSettlePrice': '',
'unassemblePurchaseMonthSettlePrice': '',
'assemblePurchaseMonthSettlePrice': '',
'unassemblePurchaseCashSettlePrice': '',
'assemblePurchaseCashSettlePrice': '',
'referencePrice': '',
'referenceLink': '',
'timeliness': '',
'remark': '' ,
'xxxx':''
}
将一个对象的部分字段值赋值给另一个对象
Object.keys(editPorductParams ).forEach((key) => {
editPorductParams [key] = resObj [key]
})
全部字段赋值
editPorductParams = {
...resObj
}
Object.assign(editPorductParams,resData)
const newData = { ...editPorductParams , ...resData}