【问题标题】:How to update the URL in the address bar but without reload to that URL?如何更新地址栏中的 URL 但不重新加载到该 URL?
【发布时间】:2016-07-16 21:21:23
【问题描述】:

如何更新地址栏中的 URL 但不重新加载到该 URL?

我找到了 2 个解决方案:

解决方案 1
阅读这里https://stackoverflow.com/a/4059844/2642351
使用window.history.replaceState。 但是,当我在我的 angularjs 项目中实现它时,它会立即恢复之前的 URL。

解决方案 2
阅读这里https://stackoverflow.com/a/24102139/2642351
但是,这适用于 ngRoute,我使用的是 uiRouter。 uiRouter中是否有类似的解决方案?

【问题讨论】:

标签: javascript angularjs html angular-ui-router


【解决方案1】:

您可以使用 $location.path() 更改 url 而无需重新加载它。您可以从下面给出的链接中了解它。

Information on $location

【讨论】:

    猜你喜欢
    • 2020-06-20
    • 2013-03-20
    • 2012-11-05
    • 2016-06-08
    • 2011-03-21
    • 2019-03-26
    • 1970-01-01
    相关资源
    最近更新 更多