如何从Web Flutter中的网址中删除井号(#) [英] How to remove hashtag (#) from url in web flutter
本文介绍了如何从Web Flutter中的网址中删除井号(#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Flutter Web项目的默认URL默认情况下定义一个包含井号(#
)的URL,如下所示:
The default url of a Flutter web project defines by default a url containing a hashtag (#
), as follows:
http://localhost:41521/#/peaple/...
我只能轻松地从中操纵所有术语( #/ ...
)。
因此,我想用另一个术语代替它或删除此#,看起来像这样:
I can only easily manipulate all terms from it ("#/...
").
So, I would like to replace this with another term or remove this '#', looking like this:
http://localhost:41521/web/peaple/
或
http://localhost:41521/peaple/
我该如何解决这个问题?
How can I solve this problem?
推荐答案
如果您只关心路由,则可以执行以下操作
If your only concern is for routing, you can do something like this:
onGenerateRoute: (settings) {
List segments = settings.name.split('/').where((x) => ! x.isEmpty).toList();
String page = segments.length > 0 ? segments[0] : '';
...
}
}
这篇关于如何从Web Flutter中的网址中删除井号(#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文