daily-share
daily-share copied to clipboard
关于向服务端发送文件下载的一些细节,如exelce 文件下载了(2022-3-22)
服务请求示例
Axios({
method: 'post',
url: sendURL,
responseType: 'blob', // 这个位置需要加上
})
.then((response) => {
const { status } = response;
if (status === 200) {
message.success('导出成功!');
const url1 = window.URL.createObjectURL(new Blob([response.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' }));
const link = document.createElement('a');
link.href = url1;
link.setAttribute('download', filename);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} else {
message.error('导出失败');
}
});