下载请求完成后调用功能
目前,我正在尝试在请求完成后执行此回电功能,因此我能够关闭
function handleDownloadFinished(): void{
setDownloadingActivity(false);}
我希望此代码在此之后运行的模式:
public static async exportData(id: number, _callback: Function): Promise<void> {
const queryString = stringifyQuery(
{
token: BaseAPI.getJwt(),
},
{
arrayFormat: "bracket",
}
);
const anchorElement = document.createElement("a");
anchorElement.download = "file.xlsx";
anchorElement.href = `URL`;
anchorElement.click();
_callback();}
不幸的是,它同时运行两个功能,然后动画不运行。有时候,我可以进行动画运行,但不停。现在,要使它起作用,该应用程序依靠用户输入来阻止其运行。
I'm currently trying to get execute this call back function after the request is finished, so I'm able to close the modal where
function handleDownloadFinished(): void{
setDownloadingActivity(false);}
I want this code to run after this:
public static async exportData(id: number, _callback: Function): Promise<void> {
const queryString = stringifyQuery(
{
token: BaseAPI.getJwt(),
},
{
arrayFormat: "bracket",
}
);
const anchorElement = document.createElement("a");
anchorElement.download = "file.xlsx";
anchorElement.href = `URL`;
anchorElement.click();
_callback();}
Unfortunately, It runs both functions at the same time, and then the animation does not run. Some times, I'm able to make the animation run, but not stop. Right now, to have It working, the application relies on user input to stop it running.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
浏览器不会以任何方式将下载文件的进度传达给网页。因此,您的代码无法知道何时下载完成。
您只需要考虑到这个事实,就必须设计您的UI。
The browser does not communicate the progress of downloaded files to a webpage in any way. So you code cannot know when a download has finished.
You're just going to have to design your UI with this fact in mind.