lor*_*has 1 flutter flutter-web
我想知道为什么 URL 中有主题标签?对于 Flutter Web 应用程序,例如:http://localhost:64392/#/home即使在生产中也是相同的结果。
我想知道为什么以及是否可以删除它?
要删除#URL 中的 ,请参阅此处:
要将 Flutter 配置为使用路径,请使用 SDK 中 flutter_web_plugins 库提供的 usePathUrlStrategy 函数:
Run Code Online (Sandbox Code Playgroud)import 'package:flutter_web_plugins/url_strategy.dart'; void main() { usePathUrlStrategy(); runApp(ExampleApp()); }
并将其添加到您的pubsepc.yaml:
import 'package:flutter_web_plugins/url_strategy.dart';
void main() {
usePathUrlStrategy();
runApp(ExampleApp());
}
Run Code Online (Sandbox Code Playgroud)
此外,您还可以使用该go_router包。
请参阅关闭哈希:
Run Code Online (Sandbox Code Playgroud)void main() { // turn on the # in the URLs on the web (default) // GoRouter.setUrlPathStrategy(UrlPathStrategy.hash); // turn off the # in the URLs on the web GoRouter.setUrlPathStrategy(UrlPathStrategy.path); runApp(App()); }
| 归档时间: |
|
| 查看次数: |
1708 次 |
| 最近记录: |