后端接口返回base64文件流
<a
@click="downloadFiles(item.fileName, item.url)"
>{{ item.fileName }}</a
>
async downloadFiles(fileName, url) {
const splitArr = url.split(".");
const splitStr = splitArr[splitArr.length - 1];
const ret = await getCourtInvestDeductAttachDownload({ url });
if (ret.retCode === 0) {
const a = document.createElement("a");
a.download = `${fileName}.${splitStr}`;
a.href = `data:;base64,${ret.data.fileBase64}`;
a.id = "download-id";
document.querySelector("body").append(a);
a.click();
document.querySelector("#download-id").remove();
}
},