<Button key="out" onClick={async () => { const values = searchConfig?.form?.getFieldsValue(); const res = await exportExcel(values); console.log(res); const blob = new Blob([res]) ; const fileName = "data.xls"; //下载的文件名称 if ('download' in document.createElement('a')) { // 非IE下载 const elink = document.createElement('a'); elink.download = fileName; elink.style.display = 'none'; elink.href = URL.createObjectURL(blob); document.body.appendChild(elink); elink.click(); URL.revokeObjectURL(elink.href); // 释放URL 对象 document.body.removeChild(elink); } else { // IE10+下载 navigator.msSaveBlob(blob, fileName); } }} > 导出 <DownOutlined /> </Button>,
ant-design-pro实现请求后台接口下载excel功能的demo
于 2022-04-30 19:40:03 首次发布