设置为'arraybuffer'后当响应是400或500时也会下载下来,因此转位JSON对象做判断
const result = await Promise.all(promise); if (result) { try { // 转换成功 let enc = new TextDecoder('utf-8'); let resp = JSON.parse(enc.decode(new Uint8Array(result[0]))); if (resp && (resp.httpCode === 400 || resp.httpCode === 500)) { ErrorTip(resp.msg); self.flag = false; self.$emit("closeDownloader",0); } } catch { // 返回的不是JSON对象 下载 val.dataStream.push(...result); self.saveFileDownload(val); } }