如果我理解正确的话,你有一个带有 url 的页面/?a=1&b=2,你想/?a=1&b=5使用 JavaScript 导航。// grab the search query, parse it into a `URLSearchParams` setconst queryData = new URLSearchParam(window.location.search.slice(1))// manipulate the parameters as desiredqueryData.set("b", 5)// assemble the new URL using the current URL as the baseconst newUrl = new URL(window.location.href)newUrl.search = queryData// redirect to the new URLwindow.location.href = newUrl