jquery的$.ajax不支持POST返回blod文件流格式
可以自己用原生写
let url = "url";
let xhr = new XMLHttpRequest();
xhr.open('POST', url, true); // 请求方式,地址,是否异步
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.responseType = "blob"; // 返回类型blob
xhr.onload = function () {
// 请求完成
const elink = document.createElement('a');
elink.style.display = 'none';
const blob = new Blob([this.response]);
const blobUrl = window.URL.createObjectURL(blob);
elink.href = blobUrl;
elink.download = '文件名';
document.body.appendChild(elink);
elink.click();
document.body.removeChild(elink);
$.modal.closeLoading();
};
// 发送ajax请求
xhr.send(JSON.stringify(param));