vue下载文件流

113 阅读1分钟

report2bExport(par).then(res => {

            const blob = new Blob([res], { type: 'application/x-excel;charset=UTF-8' });
            const _href = URL.createObjectURL(blob);     
            const aLink = document.createElement('a');
            aLink.style.display = 'none';
            aLink.href = _href;
            aLink.setAttribute('download', 'C端明细报表.xlsx');
            document.body.appendChild(aLink);
            aLink.click();
            document.body.removeChild(aLink);
            URL.revokeObjectURL(_href);
        });

下载

` handleDownload(row) {

        const a = document.createElement('a');
        
        a.href = row.agreementUrl;
        
        a.download = row.businessSubject;
        
        a.click();
        
        this.$message.success('下载成功');
    }    `