arg
参数名 val
修改的参数值
refreshSilent(arg, val) {
const url = location.href;
const pattern = arg + "=([^&]*)";
const replaceText = arg + "=" + val;
const replaceUrl = url.match(pattern)
? url.replace(eval("/(" + arg + "=)([^&]*)/gi"), replaceText)
: url.match("[?]")
? url + "&" + replaceText
: url + "?" + replaceText;
window.history.pushState({}, "", replaceUrl);
}
使用前
http://192.168.2.97:8080/seniorSearchPage?name=更改请求
调用
refreshSilent("name", "test")
使用后
http://192.168.2.97:8080/seniorSearchPage?name=test