vue 文件下載實現


downloadExcel() { this.$ajax .post( downloadExcelTemplateProte, //接口 data, //參數 {responseType: "blob"} //數據返回類型 ) .then((res) => { let url = window.URL.createObjectURL(new Blob([res.data])); let link = document.createElement("a"); link.style.display = "none"; link.href = url; link.setAttribute("download", "all_sample_fa_kegg_blast_bst.xls"); //指定下載后的文件名,防跳轉 document.body.appendChild(link); link.click(); }) .catch(function (error) { console.log(error); }); } 
   
鏈接:https://www.jianshu.com/p/c81a03b0a349 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM