URLSearchParams:getAll() 方法
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
接口的 getAll()
方法以数组的形式返回与指定查询参数对应的所有值。
语法
js
getAll(name)
参数
name
-
要返回的参数的名称。
返回值
一个字符串的数组,如果没有找到给定参数的值,则其可以是空的。
示例
js
let url = new URL("https://example.com?foo=1&bar=2");
let params = new URLSearchParams(url.search);
// 为 foo 添加第二个参数
params.append("foo", 4);
console.log(params.getAll("foo")); // 输出 ["1", "4"]。
规范
Specification |
---|
URL # dom-urlsearchparams-getall |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getAll |
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.