Skip to main content

PerformanceObserver 🧪

金丝雀发布 🧪

此 API 目前仅在 React Native 的 Canary 和 Experimental 渠道中可用。

¥This API is currently only available in React Native’s Canary and Experimental channels.

如果你想尝试,请在你的应用中使用 启用 Canary 版本通道

¥If you want to try it out, please enable the Canary Channel in your app.

全局 PerformanceObserver 类,如 Web 规范中定义。

¥The global PerformanceObserver class, as defined in Web specifications.

示例

¥Example

ts
const observer = new PerformanceObserver(
(list, observer, options) => {
for (const entry of list.getEntries()) {
console.log(
'Received entry with type',
entry.entryType,
'and name',
entry.name,
'that started at',
entry.startTime,
'and took',
entry.duration,
'ms',
);
}
},
);

observer.observe({entryTypes: ['mark', 'measure']});

参考

¥Reference

构造函数

¥Constructor

PerformanceObserver()

参见 MDN 中的文档

¥See documentation in MDN.

静态属性

¥Static properties

supportedEntryTypes

参见 MDN 中的文档

¥See documentation in MDN.

返回 ['mark', 'measure', 'event', 'longtask']

¥Returns ['mark', 'measure', 'event', 'longtask'].

实例方法

¥Instance methods

observe()

参见 MDN 中的文档

¥See documentation in MDN.

disconnect()

参见 MDN 中的文档

¥See documentation in MDN.