美文网首页
pdf下载 预览

pdf下载 预览

作者: 如果俞天阳会飞 | 来源:发表于2020-05-26 14:41 被阅读0次
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

相关文章

网友评论

      本文标题:pdf下载 预览

      本文链接:https://www.haomeiwen.com/subject/getvahtx.html