Implementation of functions antd-pro, the front page can be written
<Button onClick={this.onDownLoadClick}> 下载</Button>
onDownLoadClick = () => {
const fileName = "下载文件.txt";
const { dispatch } = this.props;
dispatch({
type: 'list/download',
payload: {
"id": 64,
},
callback: (response) => {
console.log(response)
// if (response.success) {
const blob = new Blob([response]);
const aLink = document.createElement('a');
aLink.style.display = 'none';
aLink.href = blob;
aLink.download = fileName;
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink);
// }
}
});
}
But I downloaded the file content is not the content of the background needed,
I feel should be the back-end code
and later downloaded directly to the back office staff get a request to change the way,
the front end takes only
window.open('/url/download?id=1')
You can achieve download, to be honest did not know what the background