以文件流的形式下载文件

 

function exportFile(response) {
    const a = document.createElement('a');
    const name = decodeURIComponent(response.headers['content-disposition'].split('fileName=')[1]);
    a.download = name;
    a.href = URL.createObjectURL(response.data);
    a.style.display = 'none';
    document.body.appendChild(a);
    a.click();
    a.parentNode.removeChild(a);
    URL.revokeObjectURL(response.data);
}

 

posted @ 2020-04-15 09:27  Webwhl  阅读(305)  评论(0编辑  收藏  举报