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/formdata/getall/index.html | |
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/formdata/getall/index.html')
-rw-r--r-- | files/zh-cn/web/api/formdata/getall/index.html | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/formdata/getall/index.html b/files/zh-cn/web/api/formdata/getall/index.html new file mode 100644 index 0000000000..3a6ee8a53d --- /dev/null +++ b/files/zh-cn/web/api/formdata/getall/index.html @@ -0,0 +1,145 @@ +--- +title: FormData.getAll() +slug: Web/API/FormData/getAll +translation_of: Web/API/FormData/getAll +--- +<p>{{APIRef("XMLHttpRequest")}}</p> + +<p><code><strong>getAll()</strong></code>方法会返回该 {{domxref("FormData")}} 对象指定 key 的所有值。</p> + +<div class="note"> +<p><span style="font-size: 14px;"><strong>注意:</strong></span> 该方法在 <a href="/en-US/docs/Web/API/Web_Workers_API">Web Workers</a> 中可用。</p> +</div> + +<h2 id="语法">语法</h2> + +<pre class="brush: js">formData.getAll(name);</pre> + +<h3 id="append()_Parameters" name="append()_Parameters">参数</h3> + +<dl> + <dt><code>name</code></dt> + <dd>一个 {{domxref("USVString")}} 表示要检索的 key 名称。</dd> +</dl> + +<h3 id="返回">返回</h3> + +<p>一个 {{domxref("FormDataEntryValue")}} 数组。</p> + +<h2 id="示例">示例</h2> + +<p>下列代码会先创建一个空的 <code>FormData</code> 对象:</p> + +<pre class="brush: js">var formData = new FormData();</pre> + +<p>使用 {{domxref("FormData.append")}} 添加两个 <code>username 的值:</code></p> + +<pre class="brush: js">formData.append('username', 'Chris'); +formData.append('username', 'Bob');</pre> + +<p>下列 <code>getAll()</code> 方法会返回一个数组,包含了所有 <code>username</code> 的值:</p> + +<pre class="brush: js">formData.getAll('username'); // Returns ["Chris", "Bob"]</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">说明</th> + </tr> + <tr> + <td>{{SpecName('XMLHttpRequest','#dom-formdata-getall','getAll()')}}</td> + <td>{{Spec2('XMLHttpRequest')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div>{{CompatibilityTable}}</div> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatChrome(50.0)}}</td> + <td>{{CompatGeckoDesktop("39.0")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + </tr> + <tr> + <td>Available in web workers</td> + <td>{{CompatChrome(50.0)}}</td> + <td>{{CompatGeckoDesktop("39.0")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Android Webview</th> + <th>Firefox Mobile (Gecko)</th> + <th>Firefox OS (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome for Android</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(50.0)}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + <td> + <p>{{CompatVersionUnknown}}</p> + </td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(50.0)}}</td> + </tr> + <tr> + <td>Available in web workers</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(50.0)}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(50.0)}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="相关链接">相关链接</h2> + +<ul> + <li>{{domxref("XMLHTTPRequest")}}</li> + <li><a href="/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest" title="Using XMLHttpRequest">使用 XMLHttpRequest</a></li> + <li><a href="/en-US/docs/DOM/XMLHttpRequest/FormData/Using_FormData_Objects" title="DOM/XMLHttpRequest/FormData/Using_FormData_objects">使用 FormData 对象</a></li> + <li>{{HTMLElement("Form")}}</li> +</ul> |