blob: 9d38b4e20aa2ebb6fa8950a8c38c90337b57d99d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
---
title: FormData.delete()
slug: Web/API/FormData/删除
tags:
- 删除
translation_of: Web/API/FormData/delete
---
<p>{{APIRef("XMLHttpRequest")}}</p>
<p>{{domxref("FormData")}} 接口的 <code><strong>delete()</strong></code> 方法会从 <code>FormData</code> 对象中删除指定键,即 key,和它对应的值,即 value。</p>
<div class="note">
<p><strong>Note</strong>: 此方法可用于 <a href="/zh-CN/docs/Web/API/Web_Workers_API">Web Workers</a>。</p>
</div>
<h2 id="语法">语法</h2>
<pre class="brush: js">formData.delete(name);</pre>
<h3 id="参数">参数</h3>
<dl>
<dt><code>name</code></dt>
<dd>要删除的键(Key)的名字。</dd>
</dl>
<h3 id="返回">返回</h3>
<p>空。</p>
<h2 id="例子">例子</h2>
<p>以下代码将会创建一个空的 <code>FormData</code> 对象, 并且从指定的表单中获取键值对:</p>
<pre class="brush: js">var formData = new FormData(myForm);</pre>
<p>你可以通过 <code>delete()</code> 方法来删除键值对:</p>
<pre class="brush: js">formData.delete('username');</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-delete','delete()')}}</td>
<td>{{Spec2('XMLHttpRequest')}}</td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.FormData.delete")}}</p>
<h2 id="参见">参见</h2>
<ul>
<li>{{domxref("XMLHTTPRequest")}}</li>
<li><a href="/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest" title="Using XMLHttpRequest">Using XMLHttpRequest</a></li>
<li><a href="/en-US/docs/DOM/XMLHttpRequest/FormData/Using_FormData_Objects" title="DOM/XMLHttpRequest/FormData/Using_FormData_objects">Using FormData objects</a></li>
<li>{{HTMLElement("Form")}}</li>
</ul>
|