如何从 flutter web 应用程序中删除 # 符号 url
How to remove # symbol from flutter web app url
在我问这个问题的时候,是否有任何官方或更新可以让我删除 flutter web 应用程序中的 # 符号 url。
我看到了一些变通方法来实现这一点,但它们最终导致了其他问题,例如:如果没有 url
中的哈希 #,人们将无法访问该网页
由此
pub.dev 中有包调用 url_strategy。您只需要导入 pubspec.yaml 并将下面的代码复制到您的 main.dart 文件中。它会删除你的 flutter web URL
中的#
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());
}
在我问这个问题的时候,是否有任何官方或更新可以让我删除 flutter web 应用程序中的 # 符号 url。
我看到了一些变通方法来实现这一点,但它们最终导致了其他问题,例如:如果没有 url
中的哈希 #,人们将无法访问该网页由此
pub.dev 中有包调用 url_strategy。您只需要导入 pubspec.yaml 并将下面的代码复制到您的 main.dart 文件中。它会删除你的 flutter web URL
中的#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());
}