【问题标题】:Flutter Web Page Routing IssueFlutter 网页路由问题
【发布时间】:2021-11-30 19:03:27
【问题描述】:

我需要带有基本 url 的 web 应用程序

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

我更新了我在颤振网站中记录的基本网址: https://flutter.dev/docs/development/ui/navigation/url-strategies

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

在 index.html 中

根据颤振文档哈希已经启用

观察:

1.Flutter web app加载,加载时显示url,

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

2.几秒钟后它重定向到

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

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

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

【问题讨论】:

    标签: flutter flutter-web flutter-routes


    【解决方案1】:

    我建议您在“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 项目搭建脚手架时不知何故存在这些愚蠢的问题(index.html 中的href,服务工作者的错误路径等) - 在玩 GitHub 页面时发现了这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-22
      • 2023-01-31
      • 2020-10-25
      • 2013-04-04
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 2015-07-06
      相关资源
      最近更新 更多