機能の実装がantdプロ、フロントページを書き込むことができます
<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);
// }
}
});
}
しかし、私は、ファイルのコンテンツをダウンロードし必要なバックグラウンドの内容ではありません、
私の感触は、バックエンドのコードであるべき
方法を変更する要求を取得し、以降のバックオフィスのスタッフに直接ダウンロード、
フロントエンドだけ取ります
window.open('/url/download?id=1')
あなたはどのような背景を知りませんでした正直に言うと、ダウンロードを達成することができます