📌  相关文章
📜  如何在javascript代码示例中更改url的查询参数

📅  最后修改于: 2022-03-11 15:04:20.705000             🧑  作者: Mango

代码示例2
// Construct URLSearchParams object instance from current URL querystring.
var queryParams = new URLSearchParams(window.location.search);
 
// Set new or modify existing parameter value. 
queryParams.set("myParam", "myValue");
 
// Replace current querystring with the new one.
history.replaceState(null, null, "?"+queryParams.toString());

// OR do a push to history
tory.pushState(null, null, "?"+queryParams.toString());