用promise实现一个promise.all
let PromiseAll = (promises)=>{ return new Promise((resolve, reject)=>{ let results = new Array(promises.length) for(let i=0;i<promises.length;i++){ let promise = promises[i] promise.then(res => { results[i] = res if(i === promises.length-1){ resolve(results) } }).catch(err => { reject(err) }) } }) }