Flutter 网页路由问题

Flutter Web Page Routing Issue

我需要以 url 为基础的网络应用程序

https://example.com/mojjo-test/index.html#/ 

我按照 flutter 网站上的记录更新了我的基础 url: https://flutter.dev/docs/development/ui/navigation/url-strategies

 <base href="/mojjo-test/">

在index.html

根据 flutter 文档哈希已经启用

观察:

1.Flutter 网络应用加载,加载时显示 url,

    http://example.com/mojjo-test/index.html

2.And 几秒钟后重定向到

    http://example.com/mojjo-test/#/
  1. 现在如果我们进行刷新,浏览器将尝试加载 http://example.com/mojjo-test/#/ 并显示访问被拒绝

我假设不是重定向到 http://example.com/mojjo-test/#/,而是应该重定向到 http://example.com/mojjo-test/index.html#/

请提供有关如何实现它的建议。我想将初始路径保持为 https://example.com/mojjo-test/index.html#/(index.html)

我建议你在'web/index.html'(添加Web时自动生成的平台项目)中注释掉href。我就是这样做的: https://github.com/maxim-saplin/flutter_web_spa_sample/blob/main/web/index.html

下面是这个应用在虚拟目录下运行的例子: https://maxim-saplin.github.io/flutter_web_spa_sample/html/#/

Flutter Web 以某种方式在 Web 项目的脚手架中存在这些愚蠢的问题([=21= 中的 href,service worker 的错误路径等)- 在玩 GitHub 时发现了这个页数。