PerformanceLongTaskTiming: phương thức toJSON()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Phương thức toJSON() của giao diện PerformanceLongTaskTiming là một bộ tuần tự hóa; nó trả về một biểu diễn JSON của đối tượng PerformanceLongTaskTiming.

Cú pháp

js
toJSON()

Tham số

Không có.

Giá trị trả về

Một đối tượng JSON là bộ tuần tự hóa của đối tượng PerformanceLongTaskTiming.

Ví dụ

Sử dụng phương thức toJSON

Trong ví dụ này, gọi entry.toJSON() trả về biểu diễn JSON của đối tượng PerformanceLongTaskTiming.

js
const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    console.log(entry.toJSON());
  });
});

observer.observe({ type: "longtask", buffered: true });

Thông số kỹ thuật

Specification
Long Tasks API
# dom-performancelongtasktiming-tojson

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

Xem thêm