aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/performanceobserver/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/performanceobserver/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/performanceobserver/index.html')
-rw-r--r--files/zh-cn/web/api/performanceobserver/index.html70
1 files changed, 70 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/performanceobserver/index.html b/files/zh-cn/web/api/performanceobserver/index.html
new file mode 100644
index 0000000000..ca70398a68
--- /dev/null
+++ b/files/zh-cn/web/api/performanceobserver/index.html
@@ -0,0 +1,70 @@
+---
+title: 性能监测对象
+slug: Web/API/PerformanceObserver
+tags:
+ - API
+ - 性能
+ - 性能记录
+ - 接口
+translation_of: Web/API/PerformanceObserver
+---
+<div>{{APIRef("Performance Timeline API")}}</div>
+
+<div><strong><code>PerformanceObserver</code></strong> 用于监测性能度量事件,在浏览器的性能时间轴记录下一个新的 {{domxref("PerformanceEntry","performance entries", '', 'true')}}  的时候将会被通知 。</div>
+
+<div></div>
+
+<div>{{AvailableInWorkers}}</div>
+
+<h2 id="构造函数">构造函数</h2>
+
+<dl>
+ <dt>{{domxref("PerformanceObserver.PerformanceObserver","PerformanceObserver()")}}</dt>
+ <dd>创建并返回一个新的 <code>PerformanceObserver</code> 对象。</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{domxref("PerformanceObserver.observe","PerformanceObserver.observe()")}}</dt>
+ <dd>指定监测的 {{domxref("PerformanceEntry.entryType","entry types")}} 的集合。 当 {{domxref("PerformanceEntry","performance entry")}} 被记录并且是指定的 <code>entryTypes</code> 之一的时候,性能观察者对象的回调函数会被调用。</dd>
+ <dt>{{domxref("PerformanceObserver.disconnect","PerformanceObserver.disconnect()")}}</dt>
+ <dd>性能监测回调停止接收 {{domxref("PerformanceEntry","性能条目", '', 'true')}}。</dd>
+</dl>
+
+<dl>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js">function perf_observer(list, observer) {
+ // Process the "measure" event
+ // 处理 "measure" 事件
+}
+var observer2 = new PerformanceObserver(perf_observer);
+observer2.observe({entryTypes: ["measure"]});</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范草案</th>
+ <th scope="col">状态</th>
+ <th scope="col">注释</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Performance Timeline Level 2', '#dom-performanceobserver', 'PerformanceObserver')}}</td>
+ <td>{{Spec2('Performance Timeline Level 2')}}</td>
+ <td><code>PerformanceObserver</code> 接口的初始定义</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div>
+<div class="hidden">此页面上的兼容性表是根据结构化数据生成的。 如果您想为数据做出贡献,请查看https://github.com/mdn/browser-compat-data并向我们发送拉取请求。</div>
+
+<p>{{Compat("api.PerformanceObserver")}}</p>
+</div>