Flutter web - Window.history.pushState 不起作用

陈伟霆

我正在尝试让 Flutter Web 应用程序将查询参数附加到 url 的末尾(在 UI 中进行选择时)而不重新加载页面

基本上我想将 URL 从http://127.0.0.1:8080/#/sites更新http://127.0.0.1:8080/#/sites?arg=1而不重新加载页面

以下行 (import 'dart:html') 在 flutter 中不起作用(URL 根本没有改变)

 window.history.pushState(null, null, '?arg1=1');

我也尝试过 js 包(https://pub.dev/packages/js),但它也不起作用。

有没有办法让它在颤振网络中工作,或者有没有其他方法可以满足我的要求?

陈伟霆

经过一番挣扎,并尝试将调用包装在 Future.delayed 中似乎可以解决该问题。

Future.delayed(
Duration(milliseconds: 100), () => window.history.replaceState(null, null, '${Uri.base.toString()}?accountId=${selectedAccount.accountId}'));

如果你有更好的答案,我很想知道。谢谢

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

AJAX 导航 + window.history.pushState:“后退”浏览器按钮不起作用

history.pushState在控制器中不起作用

如何使用window.history.pushState

flutter web onPressed按钮不起作用

window.location.href vs history.pushState-使用哪个?

SecurityError:操作不安全-window.history.pushState()

window.history.pushState刷新浏览器

带有window.history.pushState的砌体(网格)

Flutter 2.0 web 版本与 firebase 消息传递不起作用

为什么 HTTP 包在 Flutter web 中不起作用?

Cordova-window.history.back()在iOS 9中的HTML后退按钮上不起作用

window.history.back(); 在Sharepoint页面布局中不起作用

后退按钮/退格键不适用于window.history.pushState

如何检查通过Chrome devtools中的window.history.pushState()存储的状态对象?

window.history.pushState()数据,如何以及何时检索它们?

从pushstate返回时,FB React onClick不起作用

JavaScript pushState在返回的浏览器上不起作用

$(window).resize(); 不起作用

为什么navigator.push在我的Flutter Web应用程序中不起作用?

Firebase 在flutter web 上不起作用,但在android 模拟器上运行良好

Flutter DropdownButtonFormField不起作用

为Angular 2配置history.pushState

使用history.pushState时防止404

在jQuery Ajax上使用history.pushstate

通过this.history.pushState()传递状态

HTML history.pushState无法正常工作

通过 history.pushState 更改内容

AngularJS window.close不起作用

$(window).resize函数.on('click'不起作用