blob: 5030876ca8ca4ef212dd5daa9fa3982f8cd182b7 (
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
|
---
title: Client
slug: Web/API/Client
tags:
- API
- Client
- Experimental
- Interface
- NeedsTranslation
- Reference
- Service Workers
- ServiceWorkerClient
- ServiceWorkers
- TopicStub
translation_of: Web/API/Client
---
<p>{{SeeCompatTable}}{{APIRef("Service Workers API")}}</p>
<p><code>Client</code> 接口表示一个可执行的上下文,如{{domxref("Worker")}}或{{domxref("SharedWorker")}}。{{domxref("Window")}} 客户端由更具体的{{domxref("WindowClient")}}表示。 你可以从{{domxref("Clients.matchAll","Clients.matchAll()")}} 和{{domxref("Clients.get","Clients.get()")}}等方法获取<code>Client</code>/<code>WindowClient</code>对象。</p>
<h2 id="Methods">Methods</h2>
<dl>
<dt>{{domxref("Client.postMessage()")}}</dt>
<dd>向client发送一条消息。</dd>
</dl>
<h2 id="Properties">Properties</h2>
<dl>
<dt>{{domxref("Client.id")}} {{readonlyInline}}</dt>
<dd>客户端的唯一通用标识符,字符串形式。</dd>
<dt>{{domxref("Client.type")}} {{readonlyInline}}</dt>
<dd>客户端的类型,字符串形式。可能是"<code>window"</code>, "<code>worker"</code>, 或 "<code>sharedworker"。</code></dd>
<dt>{{domxref("Client.url")}} {{readonlyInline}}</dt>
<dd>客户端的URL,字符串形式。</dd>
</dl>
<h2 id="规范">规范</h2>
<table>
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('Service Workers', '#client', 'Client')}}</td>
<td>{{Spec2('Service Workers')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
{{Compat("api.Client")}}
<h2 id="See_also">See also</h2>
<ul>
<li>使用<a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker_API/Using_Service_Workers">Service Workers</a></li>
<li><a href="https://jakearchibald.github.io/isserviceworkerready/">ServiceWorker准备好了么?</a></li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promises</a></li>
</ul>
|