From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/urlsearchparams/getall/index.html | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 files/zh-cn/web/api/urlsearchparams/getall/index.html (limited to 'files/zh-cn/web/api/urlsearchparams/getall') diff --git a/files/zh-cn/web/api/urlsearchparams/getall/index.html b/files/zh-cn/web/api/urlsearchparams/getall/index.html new file mode 100644 index 0000000000..5fa3efdce2 --- /dev/null +++ b/files/zh-cn/web/api/urlsearchparams/getall/index.html @@ -0,0 +1,68 @@ +--- +title: URLSearchParams.getAll() +slug: Web/API/URLSearchParams/getAll +tags: + - API + - Experimental + - Method + - URL API + - URLSearchParams + - getAll +translation_of: Web/API/URLSearchParams/getAll +--- +

{{ApiRef("URL API")}}{{SeeCompatTable}} 

+ +

{{domxref("URLSearchParams")}}接口的getAll()方法,以数组的形式返回与指定搜索参数对应的所有值。

+ +

语法

+ +
URLSearchParams.getAll(name)
+ +

参数

+ +
+
name
+
要返回的参数的名称。
+
+ +

返回值

+ +

一个{{domxref("USVString")}}数组。

+ +

例子

+ +
let url = new URL('https://example.com?foo=1&bar=2');
+let params = new URLSearchParams(url.search.slice(1));
+
+//为foo参数添加第二个值
+params.append('foo', 4);
+
+console.log(params.getAll('foo')) //输出 ["1","4"].
+
+ +

规范

+ + + + + + + + + + + + + + + + +
规范状态说明
{{SpecName('URL', '#dom-urlsearchparams-getall', "getAll()")}}{{Spec2('URL')}}初始定义
+ +

浏览器兼容性

+ +
+ + +

{{Compat("api.URLSearchParams.getAll")}}

+
-- cgit v1.2.3-54-g00ecf