以文件流的形式下载文件

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);
}
原文地址:https://www.cnblogs.com/whlBooK/p/12703184.html