前端解决浏览器下载文件名称问题


// 下载doc url
let href = “base64编码”
let fileName = "文件名.doc
// 下载 doc
this.http.get(href, {
  observe: 'response',
  responseType: 'blob',
}).subscribe(res:Blob => {
// 返回的数据流为Blob
const file = decodeURIComponent(fileName); this._FileSaverService.save(res.body, file); this.isDownload = false; }, err => { this.isDownload = false; this.message.create('error', '下载失败!'); });

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM