工作日记

94 阅读1分钟

后台返回文件流如何下载文件

const blob = new Blob([res], {type: 'application/vnd.ms-excel'}) let downloadURL = window.URL.createObjectURL(blob)

downloadURL就是下载的路径(注:下载的文件是乱码,在请求头上加上{responseType: 'arraybuffer'}) [res]后台返回的文件流,这里必须是一个数组