1.后端无要求只要返回的文件流正确就行

2.前端接收和响应头设置直接贴代码了:

2.1.请求响应头必需设置:

下载Excel等多类型文件乱码

我懂我懂

responseType: 'blob',

 

2.2.创建blob模式下载:

下载Excel等多类型文件乱码

let headers = res.headers

let blob = new Blob([res.data], {

type: headers['Content-Type']

})

let link = document.createElement('a')

link.href = window.URL.createObjectURL(blob)

let title = this.theDocument.selected.data.thename

link.download = title

link.click()

3.大功告成

 

 

 

相关文章:

  • 2021-11-23
  • 2021-11-23
  • 2021-11-23
  • 2021-11-05
  • 2021-12-17
  • 2021-06-19
  • 2021-05-11
  • 2022-12-23
猜你喜欢
  • 2021-11-10
  • 2021-11-23
  • 2022-12-23
  • 2021-10-12
  • 2021-12-07
  • 2021-10-13
  • 2022-03-02
相关资源
相似解决方案