前端解決瀏覽器下載文件名稱問題


// 下載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