方式
export async function exportQuantityStatistics(payload) {
return fetch(`url`, {method:'POST',body:(payload)
, headers: {'Content-Type': 'application/json'}}).then(res => {
().then(blob => {
const url = (blob)
const a = ('a');
= url;
= '重命名文件.xlsx';
();
(url);
});
})
}
方式
export async function downloadFiles() {
return fetch(`url`).then(res => {
().then(blob => {
const url = (blob)
const a = ('a');
= url;
= '重命名文件.xlsx';
();
(url);
});
})
}
3.直接给a标签赋值
<a href={url} download='重命名123'>下载</a>
注意这里的download虽然也可以重命名,但是很多浏览器都不兼容