下载xslx二进制文件
请求头必须config.headers["Content-Type"] = "application/json";
设置responseType为blob或arraybuffer
// 下载文件
export const downloadFile = ({ obj, name = "", suffix = "xlsx" }) => {
const url = window.URL.createObjectURL(new Blob([obj]));
const link = document.createElement("a");
link.style.display = "none";
link.href = url;
const fileName = new Date() + "-" + name + "." + suffix;
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
this.$api["EXPORT_LOGLIST"]({
...data,
includes: ["index", "@timestamp", "message", ...this.selectedField],
excludes: [],
}).then((res) => {
downloadFile({ obj: res });
});
//导出日志
EXPORT_LOGLIST(data) {
return request({
url: "/search/conditionSearch/export",
responseType: "blob",
method: "post",
data,
});
},
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。