鍍金池/ 問答/HTML/ 循環(huán)請(qǐng)求數(shù)據(jù)怎么保證數(shù)據(jù)的順序

循環(huán)請(qǐng)求數(shù)據(jù)怎么保證數(shù)據(jù)的順序

我有一個(gè)循環(huán)請(qǐng)求數(shù)據(jù)列表的功能,但是有時(shí)返回的數(shù)據(jù)列表展現(xiàn)的順序不一致
有什么方法能讓他固定按序展示

let orderList = ['af123sdfs33242','sdf3323sdfsdfsd'].split(',');
let query = null ;
for(let id of orderList) {
    query = HttpServerObj.getByJSON(CONFIG.payDetail + id)
        .then((result) => {
            if (result.code === '200') {
                this.state.payDetail.push(result.data);
            }
        });
}
return query;
回答
編輯回答
大濕胸

如果循環(huán)體內(nèi)部用async/await呢?

2017年3月28日 20:46