PWA在Github页面上

Maj*_*jka 5 javascript github github-pages progressive-web-apps

我正在我的页面上工作PWA,我正在关注100%这个简单的代码框 - https://codelabs.developers.google.com/codelabs/add-to-home-screen/#0一切正常(在使用exmaple代码,也在我自己的网页上),但只有当我在localhost上测试它.在github页面上部署后,我遇到了很多错误:

  1. GET https://[myusername].github.io/manifest.json 404 () (即路径可能有问题,因为我猜在清单文件之前应该有项目名称)
  2. Manifest: Line: 1, column: 1, Unexpected token. (在devtools中我可以看到虽然它是正常的json文件,但它在我的localhost上工作正常);
  3. TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script.
  4. 在devtools中单击"添加到主屏幕"后,我得到了:Manifest: Line: 1, column: 1, Unexpected token.Site cannot be installed: the manifest could not be fetched, is empty, or could not be parsed.

有任何想法吗?我不知道我做错了什么或者github页面出了什么问题......

小智 4

看起来service-worker.jsmanifest.json文件可能已以某种方式损坏,因为即使多次下载,我也无法在计算机上打开这两个文件。(我正在看/final文件夹)

我还建议查看 Github 上已有的其他 PWA,例如pwarocks,看看他们如何使用 Github Pages 实现 PWA。