var originalData = [ { name:'小123', data:[{id:'1',trade_date:'20121213',profit:'1'},{id:'2',trade_date:'20151223',profit:'9'}] }, { name:'小456', data:[{id:'1',trade_date:'20131213',profit:'1'},{id:'2',trade_date:'20171221',profit:'9'}] }, { name:'小789', data:[{id:'1',trade_date:'20111213',profit:'1'},{id:'2',trade_date:'20181220',profit:'9'}] }, { name:'小246', data:[{id:'1',trade_date:'20171213',profit:'1'},{id:'2',trade_date:'20191203',profit:'9'}] }, ] this.worker = this.$worker .run((originalData)=>{ let st = new Date().getTime(); let len = originalData.length; console.log(' startTime ====> ',st); var allDates = new Set(); originalData.forEach((cData)=>{ cData.data.forEach((item)=>{ allDates.add(item.trade_date) }) }); let sortDate = Array.from(allDates).sort((a,b)=>{ return (+a)-(+b); }) var newArr = Array.from({ length: len }, () => []); sortDate.forEach((date, d)=>{ originalData.forEach((rDate, index)=>{ if(!newArr[index]){newArr[index]=[]} let hasData = rDate.data.find((fd)=>fd.trade_date===date) if(hasData){ newArr[index][d] = hasData.profit; }else{ newArr[index][d] = null; } }) }) originalData.forEach((rDate,index)=>{ rDate.data = newArr[index]; rDate.dateData = sortDate; }); newArr = []; console.log(' startTime ====> ',(new Date().getTime() - st)/1000); return originalData; },[res]) .then((fixedArr)=>{ that.proData = fixedArr fixedArr = []; }) 优化此代码