URLSearchParams:append() 方法
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
备注: 此特性在 Web Worker 中可用。
URLSearchParams
接口的 append()
方法将指定的键/值对附加为新的查询参数。
如下面的示例所示,如果同一个键被多次附加,则它将为每个值多次出现在参数字符串中。
语法
js
append(name, value)
参数
返回值
无(undefined
)。
示例
js
let url = new URL("https://example.com?foo=1&bar=2");
let params = new URLSearchParams(url.search);
// 添加第二个 foo 查询参数。
params.append("foo", 4);
// 查询字符串变成:“foo=1&bar=2&foo=4”
规范
Specification |
---|
URL # dom-urlsearchparams-append |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
append |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.