{"info":[{"Id":1,"new":true,"name":"james","goods":"iphone"},{"Id":3,"new":true,"name":"Chen","goods":"SM"}],"combo":[{"comboPlay":"oneByTwo","count":10},{"comboPlay":"special","count":15},{"comboPlay":"specialTwo","count":1}],"comboRef":[{"combo":"yes","payOut":310.25,"type":2},{"combo":"yes","payOut":200.35,"type":2},{"combo":"yes","payOut":250.10,"type":1}]}要用上面的数据组出下面的结构{"info":[{"Id":1,"name":"james","goods":"iphone"},{"Id":3,"name":"Chen","goods":"SM"}],"combo":[{"comboPlay":"oneByTwo","count":10,"payOut":310.25,"type":2},{"comboPlay":"special","count":15,"payOut":200.35,"type":2},{"comboPlay":"specialTwo","count":1,"payOut":200.35,"type":1}]}组完的info的内容都来自于原始数据的info而组完的combo的内容是由原始数据的combo和comboRef组出的这比较麻烦有没有什么好方法可以组出这个数据?
2 回答
qq_遁去的一_1
TA贡献1725条经验 获得超7个赞
letgo={"info":[{"Id":1,"new":true,"name":"james","goods":"iphone"},{"Id":3,"new":true,"name":"Chen","goods":"SM"}],"combo":[{"comboPlay":"oneByTwo","count":10},{"comboPlay":"special","count":15},{"comboPlay":"specialTwo","count":1}],"comboRef":[{"combo":"yes","payOut":310.25,"type":2},{"combo":"yes","payOut":200.35,"type":2},{"combo":"yes","payOut":250.10,"type":1}]}functioncombination(data){varcomparison=data.comboRef;data.combo.map((v,i)=>{Object.assign(v,comparison[i])})deletedata.comboRefreturndata}console.log(combination(go))
添加回答
举报
0/150
提交
取消