LayoutShiftAttribution: toJSON() 方法
LayoutShiftAttribution 介面的 toJSON() 方法是一個序列化器,它會返回 LayoutShiftAttribution 物件的 JSON 表示形式。
語法
js
toJSON()
引數
無。
返回值
一個 JSON 物件,是 LayoutShiftAttribution 物件的序列化表示。
示例
以下示例會將 LayoutShift.sources 中第一個元素的 JSON 表示形式列印到控制檯。
js
new PerformanceObserver((list) => {
for (const { sources } of list.getEntries()) {
if (sources) {
console.log(sources[0].toJSON());
}
}
}).observe({ type: "layout-shift", buffered: true });
規範
| 規範 |
|---|
| 佈局不穩定 API # sec-layout-shift-attribution |
瀏覽器相容性
載入中…