2017-09-14 159 views
2

我正在使用PWA在我的頁面上,並且我正在關注100%這個簡單的codelab - https://codelabs.developers.google.com/codelabs/add-to-home-screen/#0,一切工作正常(使用exmaple代碼,也在我自己的網頁上),但僅限於我在本地主機上測試它。 在github頁部署之後,我得到了很多的錯誤:Github上的PWA頁面

  1. GET https://[myusername].github.io/manifest.json 404()(即 有可能是路徑不對,因爲應該有項目名稱前清單文件,我猜)
  2. Manifest: Line: 1, column: 1, Unexpected token.(在devtools中,我可以看到雖然它是普通的json文件,並且在我的本地主機上工作正常)。
  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頁面有什麼問題...

回答

0

看起來像service-worker.jsmanifest.json文件可能已經損壞了,因爲我無法打開我的任何一個文件電腦甚至有多個下載。 (我正在查看/final文件夾)

我還建議查看Github上已有的其他PWA,例如pwarocks,以瞭解他們如何使用Github Pages取消PWA。

+0

那麼,對我來說,文件本身工作正常(+在我自己的項目中的新文件,基於本教程),但只在localhost測試,而不是在github上發佈後。也許我應該檢查另一個來源,但這似乎是最簡單的。 – Majka