解决Promise.all中某一个promise失败而使整个promise失败问题

      const promiseList = this.dataList.map(async o => {
          o.richText = await downloadRichText({ key: o.changeCode }).then(res => {
            return decodeURI(res.data);
          });
        return o;
      })
      Promise.all(promiseList.map(res => {
        return res.then(() => {
          return res;
        }).catch(err => err);
      })
      ).then(res => {
        this.dataList = res;
      }).catch(err => {
        throw new Error('失败', err);
      });

以上代码Eslint会报错require-atomic-updates,可使用"require-atomic-updates": "off"解决。

posted @ 2022-04-27 10:52  勤勤恳恳小码农  阅读(146)  评论(0)    收藏  举报