ES6对象 新增 删除

 1           // 获取 res.data 里面的数据 采用 ...丢进 this.shopForm
 2           this.shopForm = {
 3             ...res.data,
 4             // 对数据进行添加 但是 res.data 里面的数据 会重复
 5             ...{
 6                 total: res.data.stock,
 7                 msgList: res.data.detail,
 8                 bannersList: res.data.banners,
 9                 listImage: res.data.cover,
10                 id: this.id
11             }
12           }
13           console.log(this.shopForm)
14           // 采用 ES6 删除删除重复的数据
15           const { detail, banners, stock, cover, ...shopForm } = this.shopForm
16           this.shopForm = shopForm
17           console.log(this.shopForm)

 

 

 

posted @ 2020-10-15 10:16  Salvater  阅读(312)  评论(0编辑  收藏  举报