Angular5 UI post 请求 输出 文件下载
发布时间:2020-12-17 07:04:50 所属栏目:安全 来源:网络整理
导读:this .httpClient.post(url1,JSON.parse(data1),{responseType: ‘ blob ‘ }).subscribe(data = { const link = document.createElement( ‘ a ‘ ); const blob = new Blob([data],{type: ‘ application/vnd.ms-excel ‘ }); link.setAttribute( ‘ href
this.httpClient.post(url1,JSON.parse(data1),{responseType: ‘blob‘}).subscribe(data => { const link = document.createElement(‘a‘); const blob = new Blob([data],{type: ‘application/vnd.ms-excel‘}); link.setAttribute(‘href‘,window.URL.createObjectURL(blob)); link.setAttribute(‘download‘,‘Inventory‘ + new Date().getTime() + ‘.xls‘); link.style.visibility = ‘hidden‘; document.body.appendChild(link); link.click(); document.body.removeChild(link); }); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |