diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/urlsearchparams/keys | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/urlsearchparams/keys')
-rw-r--r-- | files/zh-cn/web/api/urlsearchparams/keys/index.html | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/urlsearchparams/keys/index.html b/files/zh-cn/web/api/urlsearchparams/keys/index.html new file mode 100644 index 0000000000..2ff71529b3 --- /dev/null +++ b/files/zh-cn/web/api/urlsearchparams/keys/index.html @@ -0,0 +1,57 @@ +--- +title: URLSearchParams.keys() +slug: Web/API/URLSearchParams/keys +tags: + - API + - Experimental + - Method + - Reference + - URL API + - URLSearchParams +translation_of: Web/API/URLSearchParams/keys +--- +<p>{{APIRef("URL API")}}{{SeeCompatTable}}</p> + +<p>URLSearchParams.keys()返回一个{{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.keys();</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 key of searchParams.keys()) { + console.log(key); +} +</pre> + +<p>结果如下:</p> + +<pre>key1 +key2</pre> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div> + + +<p>{{Compat("api.URLSearchParams.keys")}}</p> +</div> + +<h2 id="另请参考">另请参考</h2> + +<ul> + <li>其他URL相关接口: {{domxref("URL")}}, {{domxref("URLUtils")}}.</li> +</ul> |