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