Flutter App to Web through Github pages 空白屏幕
Flutter App to Web through Github pages blank screen
我有一个由 Flutter-Web 商店生成的页面,它是一个空白页面。我在控制台中有一个错误。这是在将 Flutter 的构建网络上传到 GitHub 页面后发生的。
Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('https://adamtechnologynl.github.io/') with script ('https://adamtechnologynl.github.io
/flutter_service_worker.js?v=2470069411'): A bad HTTP response code (404) was received when fetching the script.
manifest.json:1 Failed to load resource: the server responded with a status of 404 ()
manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.
manifest.json:1 Failed to load resource: the server responded with a status of 404 ()
(index):88 Failed to load app from service worker. Falling back to plain <script> tag.
(anonymous) @ (index):88
(index):47 GET https://adamtechnologynl.github.io/main.dart.js net::ERR_ABORTED 404
loadMainDartJs @ (index):47
(anonymous) @ (index):91
我找到了解决方案。当您将它放在另一个目录而不是 GitHub.
的根目录时,就会发生这种情况
所以我的代码在“https://username.github.io/demo/book-king/belasting-web-v1/”,所以最后一部分我们应该在“https://username.github.io/ 之后附加所有内容" 也在 index.html 中。您可以通过修改行(我的第17行)来解决它:
变化:
<base href="/">
进入:
<base href="/demo/book-king/belasting-web-v1/">
然后你就完成了。
我有一个由 Flutter-Web 商店生成的页面,它是一个空白页面。我在控制台中有一个错误。这是在将 Flutter 的构建网络上传到 GitHub 页面后发生的。
Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('https://adamtechnologynl.github.io/') with script ('https://adamtechnologynl.github.io
/flutter_service_worker.js?v=2470069411'): A bad HTTP response code (404) was received when fetching the script.
manifest.json:1 Failed to load resource: the server responded with a status of 404 ()
manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.
manifest.json:1 Failed to load resource: the server responded with a status of 404 ()
(index):88 Failed to load app from service worker. Falling back to plain <script> tag.
(anonymous) @ (index):88
(index):47 GET https://adamtechnologynl.github.io/main.dart.js net::ERR_ABORTED 404
loadMainDartJs @ (index):47
(anonymous) @ (index):91
我找到了解决方案。当您将它放在另一个目录而不是 GitHub.
的根目录时,就会发生这种情况所以我的代码在“https://username.github.io/demo/book-king/belasting-web-v1/”,所以最后一部分我们应该在“https://username.github.io/ 之后附加所有内容" 也在 index.html 中。您可以通过修改行(我的第17行)来解决它:
变化:
<base href="/">
进入:
<base href="/demo/book-king/belasting-web-v1/">
然后你就完成了。