将二进制流转换为需要的文件格式
downloadContent(value, name) { const link = document.createElement('a') const blob = new Blob([value], { type: 'application/octet-stream' }) const url = window.URL.createObjectURL(blob) link.href = url link.download = name + '.xlsx' link.click() window.URL.revokeObjectURL(url) },需要在下载接口的请求头中加 responseType: ‘arraybuffer’,例:
async function getDownThreatFile(params) { const res = request({ url: `firework/ioc/bath/export`, method: 'get', params, responseType: 'arraybuffer' }) return res }value:后台返回的二进制流 name:文件名 type:文件类型 具体参考文件类型