ReportingObserver: observe() method

Baseline 2026
Newly available

Since March 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Note: This feature is available in Web Workers.

Phương thức observe() của giao diện ReportingObserver hướng dẫn một reporting observer bắt đầu thu thập báo cáo trong hàng đợi báo cáo của nó.

Cú pháp

js
observe()

Tham số

Không có.

Giá trị trả về

Không có (undefined).

Ví dụ

Sử dụng cơ bản

js
const options = {
  types: ["deprecation"],
  buffered: true,
};

const observer = new ReportingObserver((reports, observer) => {
  reportBtn.onclick = () => displayReports(reports);
}, options);

observer.observe();

Thông số kỹ thuật

Thông số kỹ thuật
Reporting API
# dom-reportingobserver-observe

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

Xem thêm