InterventionReportBody: toJSON() 方法
注意:此功能在 Web Workers 中可用。
InterventionReportBody 接口的 toJSON() 方法是一个序列化器,它返回 InterventionReportBody 对象的 JSON 表示形式。
语法
js
toJSON()
参数
无。
返回值
一个 JSON 对象,它是 InterventionReportBody 对象的序列化结果。
示例
在此示例中,我们创建一个新的 ReportingObserver 来观察干预报告,然后返回第一个条目的 JSON 表示形式。
js
const options = {
types: ["intervention"],
buffered: true,
};
const observer = new ReportingObserver((reports, observer) => {
const firstReport = reports[0];
console.log(firstReport.toJSON());
}, options);
规范
| 规范 |
|---|
| 干预报告 # dom-interventionreportbody-tojson |
浏览器兼容性
加载中…