1.去除url中#:

使用url_strategy包

url_strategy | Dart Package

import 'package:url_strategy/url_strategy.dart';

void main() {
  // Here we set the URL strategy for our web app.
  // It is safe to call this function when running on mobile or desktop as well.
  setPathUrlStrategy();
  runApp(MyApp());
}

2.处理直接访问404

在flutter web目录下新建访问的地址文件夹,创建index.html文件,index.html内写入重定向语句

如:

index.html:

<head>
    <script type="text/javascript">
        var currentUrl = window.location.href;
        console.log(currentUrl);
        const arr=currentUrl.split('/collect');
        window.location.assign(arr[0]+arr[1]);

    </script>

</head>

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐