1. Axios({
    2. url: `xxxxxxxxxxxx`,
    3. method: 'post',
    4. responseType: 'blob', // 响应类型
    5. data: {....},
    6. }).then((res) => {
    7. if (res.status == 200) {
    8. // 处理load事件。该事件在读取操作完成时触发
    9. // 新建个下载的a标签,完成后移除。
    10. const aLink = document.createElement("a");
    11. document.body.appendChild(aLink);
    12. aLink.style.display = "none";
    13. let blob = new Blob([res.data])
    14. const objectUrl = window.URL.createObjectURL(blob);
    15. aLink.href = objectUrl;
    16. aLink.download = '导出API.zip';
    17. aLink.click();
    18. document.body.removeChild(aLink);
    19. };
    20. }).catch(err => {
    21. message.error(err || 'api导出页导出接口异常')
    22. });