matchAll()
方法在
Clients
interface returns a
Promise
for a list of service worker
Client
objects. Include the
选项
parameter to return all service worker clients whose origin is the same as the associated service worker's origin. If options are not included, the method returns only the service worker clients controlled by the service worker.
self.clients.matchAll(options).then(function(clients) {
// do something with your clients list
});
选项
可选
includeUncontrolled
: A
布尔
— if set to
true
, the matching operation will return all service worker clients who share the same origin as the current service worker. Otherwise, it returns only the service worker clients controlled by the current service worker. The default is
false
.
type
: Sets the type of clients you want matched. Available values are
"window"
,
"worker"
,
"sharedworker"
,和
"all"
。默认为
"all"
.
Promise
that resolves to an array of
Client
objects. In Chrome 46/Firefox 54 and later, this method returns clients in most recently focused order, correct as per spec.
clients.matchAll(options).then(function(clientList) {
for (var i = 0 ; i < clientList.length ; i++) {
if (clientList[i].url === 'index.html') {
clients.openWindow(clientList[i]);
// or do something else involving the matching client
}
}
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
服务工作者
The definition of 'Clients: matchall' in that specification. |
工作草案 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
matchAll
|
Chrome
47
注意事项
|
Edge
≤79
注意事项
|
Firefox
44
注意事项
|
IE 不支持 No | Opera 32 | Safari 不支持 No |
WebView Android
47
注意事项
|
Chrome Android
47
注意事项
|
Firefox Android
44
|
Opera Android 32 | Safari iOS 不支持 No |
Samsung Internet Android
4.0
注意事项
|
includeUncontrolled
option
|
Chrome
47
注意事项
|
Edge
≤79
注意事项
|
Firefox
45
注意事项
|
IE 不支持 No | Opera 38 | Safari 不支持 No |
WebView Android
47
注意事项
|
Chrome Android
47
注意事项
|
Firefox Android
45
注意事项
|
Opera Android 41 | Safari iOS 不支持 No |
Samsung Internet Android
5.0
注意事项
|
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
Clients
claim()
get()
matchAll()
openWindow()
缓存
CacheStorage
Client
ExtendableEvent
FetchEvent
InstallEvent
Navigator.serviceWorker
NotificationEvent
PeriodicSyncEvent
PeriodicSyncManager
PeriodicSyncRegistration
ServiceWorker
ServiceWorkerContainer
ServiceWorkerGlobalScope
ServiceWorkerRegistration
SyncEvent
SyncManager
SyncRegistration
WindowClient