是否要用流解释?
跟excel一页。可能是。
应该是postMan有自动转换的功能做了解析的工作。所有可以。
具体代码如下
axios({
method: "post",
url: `${process.env.VUE_APP_ASSET}/assetScanning/task/pdfExport`, // 请求地址
data: params, // 参数
responseType: "blob" // 表明返回服务器返回的数据类型
}).then(res => {
// 处理返回的文件流
const content = res.data;
const blob = new Blob([content]);
const fileName = "report.pdf";
if ("download" in document.createElement("a")) {
// 非IE下载
const elink = document.createElement("a");
elink.download = fileName;
elink.style.display = "none";
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href); // 释放URL 对象
document.body.removeChild(elink);
} else {
// IE10+下载
navigator.msSaveBlob(blob, fileName);
}
});