前端文档流下载文件

后端返回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) //重要 重要 重要


版权声明:本文为qq_45059900原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。