在angularjs中通过history.replacestate更改url时如何停止页面刷新?
Posted
技术标签:
【中文标题】在angularjs中通过history.replacestate更改url时如何停止页面刷新?【英文标题】:How to stop page refresh when changing url by history.replacestate in angularjs? 【发布时间】:2019-09-30 04:33:02 【问题描述】:我正在通过在我的 angularjs+jade+nodejs 应用程序中单击跨度来更新我的页面 URL。 http://192.xxx.0.xxx:7071/page-1/blog 到 http://192.xxx.0.xxx:7071/page-2/blog
我正在使用 history.replaceState 进行更改。 但是随着函数的执行,页面会自动刷新。 我想使用 replaceState 停止重新加载。还有其他解决方案吗?
如果我在浏览器的控制台中编写 history.replacestate(null, null, '/page-2/blog') ,它工作得很好。
【问题讨论】:
【参考方案1】:你应该看看 "reloadOnSearch: false" 。
如果你在你的 angularJS 模块中添加这个,你就不能禁用刷新
[reloadOnSearch=true] - boolean= - 使用 true 重新加载路由,如果您不想刷新,则使用 false 。
【讨论】:
以上是关于在angularjs中通过history.replacestate更改url时如何停止页面刷新?的主要内容,如果未能解决你的问题,请参考以下文章
如何在angularjs中通过ajax显示来自url的json数组
在angularjs中通过history.replacestate更改url时如何停止页面刷新?