为了账号安全,请及时绑定邮箱和手机立即绑定

js 两个数组数据处理大佬们有什么好的建议?

js 两个数组数据处理大佬们有什么好的建议?

千万里不及你 2019-10-10 18:47:33
第一个数组:(6)[{…},{…},{…},{…},{…},{…}__ob__:Observer]0:dataContent:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArIA"topic:"名称"1:dataContent:(...)topic:(...)第二个数组:(6)[Array(2),Array(3),Array(4),Array(3),Array(1),Array(1)]0:Array(2)0:{content:"户籍一",grand:0,percent:0,resultCount:0,validPercent:0}1:{content:"户籍二",grand:0,percent:0,resultCount:0,validPercent:0}length:21:Array(3)0:{content:"人均500元",grand:0,percent:0,resultCount:0,validPercent:0}1:{content:"人均300元",grand:0,percent:0,resultCount:0,validPercent:0}2:{content:"人均400元",grand:0,percent:0,resultCount:0,validPercent:0}length:32:(4)[{…},{…},{…},{…}].....求两个数组的数据合并(归并)想要得到结果:[{"dataContent":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArIA","exportContent":[{"content":"户籍一","grand":"0","percent":"0","resultCount":0,"validPercent":"0"}],"topic":"名称"}]
查看完整描述

2 回答

?
哔哔one

TA贡献1854条经验 获得超8个赞

vardata1=[
{
dataContent:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArIA",
topic:"名称"
},
{
dataContent:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArIA",
topic:"名称"
},
{
dataContent:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArIA",
topic:"名称"
}
]
vardata2=[
[
{content:"户籍一",grand:0,percent:0,resultCount:0,validPercent:0},
{content:"户籍二",grand:0,percent:0,resultCount:0,validPercent:0}
],
[
{content:"户籍一",grand:0,percent:0,resultCount:0,validPercent:0},
{content:"户籍二",grand:0,percent:0,resultCount:0,validPercent:0},
{content:"户籍二",grand:0,percent:0,resultCount:0,validPercent:0}
],
[
{content:"户籍一",grand:0,percent:0,resultCount:0,validPercent:0},
{content:"户籍二",grand:0,percent:0,resultCount:0,validPercent:0}
],
]
functionmergeData(data1,data2){
returndata1.map((item,index)=>({
...item,
exportContent:data2[index]
}))
}
console.log(mergeData(data1,data2))
                            
查看完整回答
反对 回复 2019-10-10
?
一只斗牛犬

TA贡献1784条经验 获得超2个赞

                            
查看完整回答
反对 回复 2019-10-10
  • 2 回答
  • 0 关注
  • 254 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信