html - Flutter App to Web 通过 Github 页面黑屏
问题描述
我有一个由 Flutter-Web 商店生成的页面,它是一个空白页面。我在控制台中有一个错误。这是在将 Flutter 的构建 Web 上传到 GitHub Pages 之后发生的。
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/">
然后你就完成了。
推荐阅读
- python - 尝试连接 Django 和 MySQL
- python - 使用 BeautifulSoup 发送 POST 请求时出现 ViewExpiredException
- html - 子菜单的全宽背景,但保留位置
- sql - 有没有办法保持组字符串出现在 regexp_matches 查询结果中的文本中的顺序?
- reactjs - 使用 react-test-renderer 测试 Formik 验证功能
- python - 确定 numpy 数组是否为 datetime64 的最佳方法?
- r - 使用网格来注释绘图区域之外的格子图
- json - TypeError:value.forEach 不是函数 TypeError:value.forEach 不是 FormArray.patchValue 处的函数
- sql - 如何使用where子句中的父ID从另一条记录中的同一表中获取值
- javascript - 一旦我调用函数 node.js,工作线程就会被主线程终止