<>js in for Loop multiple requests , Processing of returned data out of order
// On demand processing according to usage scenarios // Use all the data returned by the request first new Promise To handle asynchronously , Store the returned data in a atemp Array const
atemp= [] for (let i = 0; i < 7; i++) { atemp.push( // use Promise For asynchronous computing new
Promise((resolve, reject) => { //queryList[i] Is the request parameter pageFindJobOrder(queryList[i]
).then(res => { return resolve(res) }).catch(err => { return reject(err) }) }) )
} // use Promise.all Put all request data atemp After you get the array , Together
// This is how it is used , The idea is like this , Data is processed on demand according to individual return , I have not intercepted all the data here Promise.all(atemp).then(res => { res
.forEach((ele, i) => { let count = 0 ele.data.data.forEach(ele => { if (ele.
status=== 'FINISH') { count++ } }) this.planNum.push(ele.data.total)
lineChartData.order.expectedData = this.planNum this.actualNum.push(count)
lineChartData.order.actualData = this.actualNum }) }).catch(err => { console.log
('error', err) })
Technology
Daily Recommendation