后端返回blob文件流,前端下载文件的整个过程,偏向于前端这边(vue+axios)_@codeDo的博客-CSDN博客_后端返回blob文件流
接口:
export function ExportWord (parameter) {
return axios({
url: api.exportWord,
method: 'post',
responseType:'blob',//重要,重要,重要
data: parameter
})
}
对返回值的函数处理:
ExportWord({
"startTime":"",
"endTime":""
}).then(res => {
console.log(res,window.URL.createObjectURL(res))//blob对象,将blob转换为下载链接
this.url= window.URL.createObjectURL(res)
})
//window.URL.createObjectURL(res) //重要 重要 重要