🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 一般请求头添加`responseType`,以流的形式传递 ***** ``` responseType:'blob',// 流  形式 ``` ![](https://img.kancloud.cn/81/88/8188c4602ff62da498144a809137f448_638x218.png) ### 导出excel常用封装 ***** ``` const contentType = { excel: 'application/vnd.ms-excel', zip: 'application/zip' } // 导出excel / zip export function downloadBlob(data, fileName, type = 'excel') {   const link = document.createElement('a')   const blob = new Blob([data], { type: contentType[type] || contentType['excel'] })   link.style.display = 'none'   link.href = URL.createObjectURL(blob)   // link.download = res.headers['content-disposition'] //下载后文件名   link.download = fileName // 下载的文件名   document.body.appendChild(link)   link.click()   document.body.removeChild(link) } ``` ### 其他信息: ***** 请求头信息: ![](https://img.kancloud.cn/8f/04/8f0462010dbb0d5e073e32f2fde7b49e_913x677.png) 返回信息: ![](https://img.kancloud.cn/bc/df/bcdf8be9a506c5c797a0e4056ce320ae_784x396.png)