pdfDownload(url){
const id = sessionStorage.getItem('idPdf').replace(/"/g, '');
this.$http({
url: `account/registerOpen/${url}`,
method: 'get',
responseType: 'arraybuffer',
params: { accountId: id, lang: 'en_US' }
}).then(res => {
// 下载pdf
if (url === 'PerPdf/download' || url === 'PerCrsPdf/download' || url === 'PerWbenContractPdf/download') {
//type类型可以设置为文本类型,这里是pdf类型
this.pdfUrl = window.URL.createObjectURL(new Blob([res], { type: `application/pdf` }));
const fname = `个人开户资料`; // 下载文件的名字
const link = document.createElement('a');
link.href = this.pdfUrl;
link.setAttribute('download', fname);
document.body.appendChild(link);
link.click();
}
});
}
下载
pdfDownload(url){
const id = sessionStorage.getItem('idPdf').replace(/"/g, '');
this.$http({
url: `account/registerOpen/${url}`,
method: 'get',
responseType: 'arraybuffer',
params: { accountId: id, lang: 'en_US' }
}).then(res => {
// 下载pdf
if (url === 'PerPdf/download' || url === 'PerCrsPdf/download' || url === 'PerWbenContractPdf/download') {
//type类型可以设置为文本类型,这里是pdf类型
this.pdfUrl = window.URL.createObjectURL(new Blob([res], { type: `application/pdf` }));
const fname = `个人开户资料`; // 下载文件的名字
const link = document.createElement('a');
link.href = this.pdfUrl;
link.setAttribute('download', fname);
document.body.appendChild(link);
link.click();
}
});
}
来源https://www.jianshu.com/p/950cb898c978?utm_campaign=hugo
网友评论