diff options
Diffstat (limited to 'files/zh-cn/web/api/urlsearchparams/entries/index.html')
-rw-r--r-- | files/zh-cn/web/api/urlsearchparams/entries/index.html | 57 |
1 files changed, 57 insertions, 0 deletions
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 +--- +<p>{{APIRef("URL API")}}{{SeeCompatTable}}</p> + +<p><code><strong>URLSearchParams.entries()</strong></code>方法返回一个{{jsxref("Iteration_protocols",'iterator')}},允许遍历该对象中包含的所有键/值对。每一组键值对都是 {{domxref("USVString")}}对象</p> + +<div class="note"> +<p><strong>注意</strong>: 该方法在 <a href="/en-US/docs/Web/API/Web_Workers_API">Web Workers</a>也是可用的.</p> +</div> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">searchParams.entries();</pre> + +<h3 id="返回值">返回值</h3> + +<p>返回一个 {{jsxref("Iteration_protocols","iterator")}}.</p> + +<h2 id="例子">例子</h2> + +<pre class="brush: js;highlight:[5]">// 创建一个测试用 URLSearchParams 对象 +var searchParams = new URLSearchParams("key1=value1&key2=value2"); + +// 显示键/值对 +for(var pair of searchParams.entries()) { + console.log(pair[0]+ ', '+ pair[1]); +} +</pre> + +<p>结果如下:</p> + +<pre>key1, value1 +key2, value2</pre> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div> +<div class="hidden">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.</div> + +<p>{{Compat("api.URLSearchParams.entries")}}</p> +</div> + +<h2 id="另请参阅">另请参阅</h2> + +<ul> + <li>其他 URL相关接口: {{domxref("URL")}}, {{domxref("URLUtils")}}.</li> +</ul> |