第一个数组:(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))
添加回答
举报
0/150
提交
取消