blob: 293957bd3d758a90faebf976f1e649ff0ff506c1 (
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
|
---
title: Headers.values()
slug: Web/API/Headers/values
translation_of: Web/API/Headers/values
---
<div>{{APIRef}}</div>
<p><code><strong>Headers.values()</strong></code>方法返回一个可迭代数值,通过这个数值可以遍历<code><strong>Headers</strong></code>中键值对的<code><strong>value</strong></code>值。返回的<code><strong>value</strong></code>都是<strong><code>ByteString</code></strong>对象。</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">headers.values();</pre>
<h3 id="返回值">返回值</h3>
<p>返回一个由键值对中<strong><code>value</code></strong>组成的数组。</p>
<h2 id="例子">例子</h2>
<pre class="brush: js;highlight:[7]">// Create a test Headers object
var myHeaders = new Headers();
myHeaders.append('Content-Type', 'text/xml');
myHeaders.append('Vary', 'Accept-Language');
// Display the values
for (var value of myHeaders.values()) {
console.log(value);
}
</pre>
<p>返回值为:</p>
<pre>text/xml
Accept-Language</pre>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<div>
<p>{{Compat("api.Headers.values")}}</p>
</div>
<h2 id="See_also">See also</h2>
<ul>
<li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li>
<li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li>
<li><a href="/en-US/docs/Web/HTTP">HTTP</a></li>
</ul>
|