Clients: phương thức get()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.

Note: This feature is only available in Service Workers.

Phương thức get() của giao diện Clients lấy một client service worker khớp với id đã cho và trả về nó trong một Promise.

Cú pháp

js
get(id)

Tham số

id

Một chuỗi biểu diễn id của client mà bạn muốn lấy.

Giá trị trả về

Một Promise được phân giải thành một đối tượng Client hoặc undefined.

Ví dụ

js
self.clients.get(id).then((client) => {
  self.clients.openWindow(client.url);
});

Thông số kỹ thuật

Thông số kỹ thuật
Service Workers Nightly
# clients-get

Tương thích trình duyệt