文章

JS导出-异常提示处理

JS导出(异常提示处理)

JS导出(异常提示处理)

导出(异常提示处理)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// 导出API获得结果(res)
const res = await this.exportList({...params.model, otpCode})
const blob = new Blob([res.data], { type: "application/vnd.ms-excel" });
const fileReader = new FileReader();
fileReader.readAsText(blob, 'utf-8');
fileReader.onloadend = () => {
  // 处理异常提示
  if (/99999/.test(fileReader.result)) {
    const result = JSON.parse(fileReader.result);
    console.log(result);
    return;
  }
  // 导出方法
  modifyExport(res);
}

本文由作者按照 CC BY 4.0 进行授权