for循环中执行promise
let promiseList = []; //promise返回值的数组 for (let obj of list) { let p = new Promise((resolve, reject) => { _this.loadLayer.text = '正在生成【' + obj.label + '】数据文件' exportList(obj.url,obj.params) .then((response) => { response.bussinessName = obj.label; resolve(response) }).catch((e) => { reject(e) }) }) promiseList.push(p); }
_this.loadLayer.loading = true; Promise.all(promiseList).then((res) => { _this.loadLayer.loading = false; console.log(res) }).catch((err) => { console.log(err) _this.loadLayer.loading = false; })
posted on 2021-04-02 14:35 object360 阅读(2870) 评论(0) 编辑 收藏 举报