diff options
Diffstat (limited to 'files/zh-cn/web/api/clients/get/index.html')
| -rw-r--r-- | files/zh-cn/web/api/clients/get/index.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/clients/get/index.html b/files/zh-cn/web/api/clients/get/index.html new file mode 100644 index 0000000000..3a9d732f63 --- /dev/null +++ b/files/zh-cn/web/api/clients/get/index.html @@ -0,0 +1,60 @@ +--- +title: Clients.get() +slug: Web/API/Clients/get +translation_of: Web/API/Clients/get +--- +<div>{{SeeCompatTable}}{{APIRef("Service Workers API")}}</div> + +<p>{{domxref("Clients")}} 接口的 <code><strong>get</strong></code><strong><code>()</code></strong> 方法 获取给定 <code>id</code> 匹配的Service Worker client,并在 {{jsxref("Promise")}} 中返回它.</p> + +<h2 id="语法">语法</h2> + +<pre class="brush: js">self.clients.get(id).then(function(client) { + // do something with your returned client +});</pre> + +<h3 id="参数">参数</h3> + +<dl> + <dt><code>id</code></dt> + <dd>一个 {{domxref("DOMString")}} ,表示您想要获取的 client id.</dd> +</dl> + +<h3 id="返回">返回</h3> + +<dl> + <dd>一个resolve为 {{domxref("Client")}} 对象的 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" title="The Promise object is used for deferred and asynchronous computations. A Promise is in one of the three states:">Promise</a></code> .</dd> +</dl> + +<h2 id="示例">示例</h2> + +<pre class="brush: js">self.clients.get(options).then(function(client) { + self.clients.openWindow(client.url); +});</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('Service Workers', '#clients-get-method', 'get()')}}</td> + <td>{{Spec2('Service Workers')}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div> + + +<p>{{Compat("api.Clients.get")}}</p> +</div> + +<p> </p> |
