history.pushState()更改查询值 [英] history.pushState() change query values
本文介绍了history.pushState()更改查询值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我的链接正在使用函数 history.pushState({},,link)进行更改;
我的链接
例如 page.php?value = 1& value2 = 2
有没有办法只更改 value2
使用 pushState()
函数而不是更改整个链接?
If I have a link that is being changed with the function history.pushState({}, "", link);
where my link
is for example page.php?value=1&value2=2
Is there a way to just change the value2
with pushState()
function instead of changing the whole link?
推荐答案
如果您要做的是更改URL而不向历史对象添加其他条目,则可以尝试 replaceState
。
If what you're trying to do is change the URL without adding an additional entry to the history object, you might try replaceState
.
history.replaceState({value: 1, value2: X}, "title", "page.php");
这篇关于history.pushState()更改查询值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文