主要逻辑:
// html
<div className={Style.maskBtn}><DownloadOutlined className={Style.maskIcon} style={{fontSize: '34px'}} onClick={() => onDownload(item)} /></div>
//js
const onDownload = (item: IconType) => {
fetch(item.filePath as string)
.then((response) => response.blob())
.then((blob) => {
const url = URL.createObjectURL(new Blob([blob]));
const link = document.createElement('a');
link.href = url;
link.download = item.fileName + '.' + item.fileFormat;
document.body.appendChild(link);
link.click();
URL.revokeObjectURL(url);
link.remove();
});
};