jisi2012
export function downloadFile(obj, name, suffix = "xlsx") {
  const url = window.URL.createObjectURL(new Blob([obj], {type: "application/vnd.ms-excel"}))
  const link = document.createElement(\'a\')
  link.style.display = \'none\'
  link.href = url
  const fileName = name + \'-\' + parseTime(new Date()) + \'.\' + suffix
  link.setAttribute(\'download\', fileName)
  document.body.appendChild(link)
  link.click()
  document.body.removeChild(link)
}

  

按照以上方式导出出现文件损坏提示, 原因是请求时少了请求头responseType: ‘blob’
在这里插入图片描述

加上请求头即可

 

 

转自:https://blog.csdn.net/qq_38392623/article/details/118020562

分类:

技术点:

相关文章:

  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2021-11-23
  • 2021-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2021-12-23
  • 2021-06-15
  • 2022-12-23
  • 2021-10-09
相关资源
相似解决方案