简体   繁体   English

在 Fetch 期间显示加载进度

[英]Show loading progress during Fetch

I followed this code to let user download files to cache to display them offline: https://serviceworke.rs/cache-from-zip.html我按照此代码让用户下载文件以缓存以离线显示它们: https://serviceworke.rs/cache-from-zip.html

It works, but with large files it can take some time so I would like to show a progress indicator while loading the zip file.它可以工作,但是对于大文件可能需要一些时间,所以我想在加载 zip 文件时显示进度指示器。

I guess it's in the fetch part that it could be done but I don't know how: https://serviceworke.rs/cache-from-zip_worker_doc.html我想它可以在获取部分完成,但我不知道如何: https://serviceworke.rs/cache-from-zip_worker_doc.html

Declare a let or var variable which is null initially.声明一个 let 或 var 变量,最初是 null。 Then during data fetch assign the response to that variable.然后在数据获取期间将响应分配给该变量。

Use an if-else statement to display a spinner while said variable is null.当所述变量为 null 时,使用 if-else 语句显示微调器。

Upload progress indicators for fetch? 上传进度指示器以获取?

Have a look here, the second answer in particular might be of help to your problem.看看这里,特别是第二个答案可能对您的问题有帮助。

EDIT: I am assuming you can derive similar information regardless of up or download - unfortunately not sure.编辑:我假设你可以得到类似的信息,无论是上传还是下载 - 不幸的是不确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM