如何在深圳找到提供高质量平谷网站建设服务的公司?

摘要:深圳优化网站关键词,平谷网站建设公司,网站符号,深圳做网站三网合一文章目录 1、location.href2、location.href3、a标签4、请求后端的方式5、文件下载的方式6、Blob和Base647、下载附件方法(excel,z
深圳优化网站关键词,平谷网站建设公司,网站符号,深圳做网站三网合一文章目录 1、location.href2、location.href3、a标签4、请求后端的方式5、文件下载的方式6、Blob和Base647、下载附件方法(excel,zip,html,markdown)8、封装下载函数9、导出 zip 压缩包相关方法(流方式) 总结 1、location.href //get请求 window.location.href url;2、locati… 文章目录 1、location.href2、location.href3、a标签4、请求后端的方式5、文件下载的方式6、Blob和Base647、下载附件方法(excel,zip,html,markdown)8、封装下载函数9、导出 zip 压缩包相关方法(流方式) 总结 1、location.href //get请求 window.location.href url;2、location.href //get请求和location.href类似 window.open(url);3、a标签 //写法1 const download (filename, url) {let a document.createElement(a); a.style display: none; // 创建一个隐藏的a标签a.download filename;a.href url;document.body.appendChild(a);a.click(); // 触发a标签的click事件document.body.removeChild(a); }4、请求后端的方式 axios({method: post,headers: {Content-Type: application/json; charsetutf-8},url: /robot/strategyManagement/analysisExcel,responseType: blob,headers: { //如果需要权限下载的话加在这里Authorization: 123456}data: JSON.stringify(params), }).then(function(res){var content res.headers[content-disposition];var name content content.split(;)[1].split(filename)[1];var fileName decodeURIComponent(name)downloadFile(res.data,fileName) }) 5、文件下载的方式 downloadFile:function(data,fileName){// data为blob格式var blob new Blob([data]);var downloadElement document.createElement(a);var href window.URL.createObjectURL(blob);downloadElement.href href;downloadElement.download fileName;document.body.appendChild(downloadElement);downloadElement.click();document.body.removeChild(downloadElement);window.URL.revokeObjectURL(href); }6、Blob和Base64 function downloadFile(res, Filename) {// res为接口返回数据在请求接口的时候可进行鉴权if (!res) return;// IE及IE内核浏览器if (msSaveOrOpenBlob in navigator) {navigator.msSaveOrOpenBlob(res, name);return;}const url URL.createObjectURL(new Blob([res]));// const fileReader new FileReader(); 使用 Base64 编码生成// fileReader.readAsDataURL(res);// fileReader.onload function() { ...此处逻辑和下面创建a标签并释放代码一致可从fileReader.result获取href值... }const a document.createElement(a);a.style.display no
阅读全文