【发布时间】:2021-05-08 09:50:13
【问题描述】:
Flutter web 项目在直接从 IDE 运行到 chrome 时运行顺利,但在调用 flutter build web 后,托管构建的 web 应用程序没有打开(只有一个空白页面)并显示此错误
Failed to load resource: the server responded with a status of 404 (Not Found)
main.dart.js:1
Failed to load resource: the server responded with a status of 404 (Not Found)
(index):1
Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('http://localhost:8080/') with script ('http://localhost:8080/flutter_service_worker.js'): A bad HTTP response code (404) was received when fetching the script.
【问题讨论】:
-
您是说您托管了该应用程序吗?就像在不在本地的网络服务器上一样?
-
是的,我在本地托管
-
好吧,我猜这个问题是由于在 URL 中使用了“localhost”,但如果它仍然在本地托管,那么这不是问题。
标签: flutter dart flutter-web