LayoutShiftAttribution: toJSON() method

Khả dụng hạn chế

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 LayoutShiftAttribution là một bộ tuần tự hóa trả về biểu diễn JSON của đối tượng LayoutShiftAttribution.

Cú pháp

js
toJSON()

Tham số

Không có.

Giá trị trả về

Một đối tượng JSON là kết quả tuần tự hóa của đối tượng LayoutShiftAttribution.

Ví dụ

Ví dụ sau in biểu diễn JSON của phần tử đầu tiên trong LayoutShift.sources vào bảng điều khiển.

js
new PerformanceObserver((list) => {
  for (const { sources } of list.getEntries()) {
    if (sources) {
      console.log(sources[0].toJSON());
    }
  }
}).observe({ type: "layout-shift", buffered: true });

Thông số kỹ thuật

Thông số kỹ thuật
Layout Instability API
# sec-layout-shift-attribution

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