FetchEvent: thuộc tính clientId

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.

Thuộc tính chỉ đọc clientId của giao diện FetchEvent trả về id của Client mà service worker hiện tại đang kiểm soát.

Phương thức Clients.get() sau đó có thể được truyền ID này để lấy client liên quan.

Giá trị

Một chuỗi đại diện cho ID của client.

Ví dụ

js
self.addEventListener("fetch", (event) => {
  console.log(event.clientId);
});

Thông số kỹ thuật

Specification
Service Workers Nightly
# fetch-event-clientid

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

Xem thêm