这篇翻译不完整。请帮忙从英语翻译这篇文章

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

Clients 接口的  matchAll() 方法返回 service worker Client 对象列表的 Promise . 包含 options 参数以返回域与关联的 service worker 的域相同所有 service worker 的 clients. 如果未包含 options,该方法仅返回由service worker控制的 service worker clients.

语法

ServiceWorkerClients.matchAll(options).then(function(clients) {
  // do something with your clients list
});

参数

options 可选
一个options对象,允许您为匹配操作设置选项。 可用选项包括:
  • includeUncontrolled: Boolean — 如果设置为true, 匹配操作将返回与当前服务工作者共享相同源的所有服务工作者客户端。 否则,它仅返回由当前服务工作者控制的服务工作者客户端。 默认值为false.
  • type: 设置想要匹配的 clients 类型. 可用值包括 window, worker, sharedworker, 和 all. 默认是 all.

返回值

resolve为一个 Client 对象数组的 Promise . 在 Chrome 46/Firefox 54 以及更高版本中, 该方法以最近关注的顺序返回 clients , 根据规范更正.

示例

clients.matchAll(options).then(function(clientList) {
  for (var i = 0 ; i < clients.length ; i++) {
    if (clientList[i].url === 'index.html') {
      clients.openWindow(clientList[i]);
      // or do something else involving the matching client
    }
  }
});

规范

Specification Status Comment
Service Workers
Clients
Working Draft Initial definition

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic support
Experimental
Chrome Full support 47
Notes
Full support 47
Notes
Notes Client objects returned in most recent focus order.
Edge ? Firefox Full support 44
Notes
Full support 44
Notes
Notes Service workers (and Push) have been disabled in the Firefox 45 & 52 Extended Support Releases (ESR).
Full support 54
Notes
Notes Client objects returned in most recent focus order.
IE No support NoOpera Full support 32Safari No support NoWebView Android Full support 47
Notes
Full support 47
Notes
Notes Client objects returned in most recent focus order.
Chrome Android Full support 47
Notes
Full support 47
Notes
Notes Client objects returned in most recent focus order.
Edge Mobile ? Firefox Android Full support 44
Full support 44
Full support 54
Notes
Notes Client objects returned in most recent focus order.
Opera Android Full support 32Safari iOS No support NoSamsung Internet Android Full support 4.0
includeUncontrolled option
Experimental
Chrome Full support 47
Notes
Full support 47
Notes
Notes Client objects returned in most recent focus order.
Edge ? Firefox Full support 45
Notes
Full support 45
Notes
Notes includeUncontrolled support.
IE No support NoOpera Full support 38Safari No support NoWebView Android Full support 47
Notes
Full support 47
Notes
Notes Client objects returned in most recent focus order.
Chrome Android Full support 47
Notes
Full support 47
Notes
Notes Client objects returned in most recent focus order.
Edge Mobile ? Firefox Android Full support 45
Notes
Full support 45
Notes
Notes includeUncontrolled support.
Opera Android Full support 38Safari iOS No support NoSamsung Internet Android Full support 5.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.

文档标签和贡献者

此页面的贡献者: flyingsouthwind
最后编辑者: flyingsouthwind,