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/entries/index.html | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 files/zh-cn/web/api/urlsearchparams/entries/index.html (limited to 'files/zh-cn/web/api/urlsearchparams/entries') diff --git a/files/zh-cn/web/api/urlsearchparams/entries/index.html b/files/zh-cn/web/api/urlsearchparams/entries/index.html new file mode 100644 index 0000000000..23e87b1b59 --- /dev/null +++ b/files/zh-cn/web/api/urlsearchparams/entries/index.html @@ -0,0 +1,57 @@ +--- +title: URLSearchParams.entries() +slug: Web/API/URLSearchParams/entries +tags: + - API + - Experimental + - Method + - Reference + - URL API + - URLSearchParams +translation_of: Web/API/URLSearchParams/entries +--- +

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

+ +

URLSearchParams.entries()方法返回一个{{jsxref("Iteration_protocols",'iterator')}},允许遍历该对象中包含的所有键/值对。每一组键值对都是 {{domxref("USVString")}}对象

+ +
+

注意: 该方法在 Web Workers也是可用的.

+
+ +

语法

+ +
searchParams.entries();
+ +

返回值

+ +

返回一个 {{jsxref("Iteration_protocols","iterator")}}.

+ +

例子

+ +
// 创建一个测试用 URLSearchParams 对象
+var searchParams = new URLSearchParams("key1=value1&key2=value2");
+
+// 显示键/值对
+for(var pair of searchParams.entries()) {
+   console.log(pair[0]+ ', '+ pair[1]);
+}
+
+ +

结果如下:

+ +
key1, value1
+key2, value2
+ +

浏览器兼容性

+ +
+ + +

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

+
+ +

另请参阅

+ + -- cgit v1.2.3-54-g00ecf