js中使用Object.assign方法给对象赋值

原先的

 this.addForm.strPrice = resPrice.result.strPrice
 this.addForm.price = resPrice.result.price
 this.addForm.priceId = resPrice.result.priceId

现在的只需一句代码搞定

Object.assign(this.addForm, resPrice.result)

减少代码冗余,提高项目的可维护性。

posted @ 2023-05-26 15:05  yuanyuanyang  阅读(7)  评论(0编辑  收藏  举报