entryType 特性返回 DOMString representing the type of performance metric such as, for example, " mark ". This property is read only.

注意: 此特征可用于 Web 工作者 .

句法

var type = entry.entryType;
					

返回值

The return value depends on the subtype of the PerformanceEntry object and affects the value of the PerformanceEntry.name property as shown by the table below.

Performance entry type names

Subtype Type of name property Description of name property
frame , navigation PerformanceFrameTiming , PerformanceNavigationTiming URL The document's address.
resource PerformanceResourceTiming URL The resolved URL of the requested resource. This value doesn't change even if the request is redirected.
mark PerformanceMark DOMString The name used when the mark was created by calling performance.mark() .
measure PerformanceMeasure DOMString name used when the measure was created by calling performance.measure() .
paint PerformancePaintTiming DOMString 要么 'first-paint' or 'first-contentful-paint' .
longtask PerformanceLongTaskTiming DOMString reports instances of long tasks

范例

The following example shows the use of the entryType 特性。

function run_PerformanceEntry() {
  // check for feature support before continuing
  if (performance.mark === undefined) {
    console.log("performance.mark not supported");
    return;
  }
  // Create a performance entry named "begin" via the mark() method
  performance.mark("begin");
  // Check the entryType of all the "begin" entries
  var entriesNamedBegin = performance.getEntriesByName("begin");
	for (var i=0; i < entriesNamedBegin.length; i++) {
      var typeOfEntry = entriesNamedBegin[i].entryType;
      console.log("Entry is type: " + typeOfEntry);
  }
}
					

规范

规范 状态 注释
Performance Timeline Level 2
The definition of 'entryType' in that specification.
候选推荐
性能时间线
The definition of 'entryType' in that specification.
推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
entryType Chrome Yes Edge 12 Firefox Yes IE Yes Opera Yes Safari 11 WebView Android Yes Chrome Android Yes Firefox Android 25 Opera Android Yes Safari iOS 11 Samsung Internet Android Yes

图例

完整支持

完整支持

元数据

  • 最后修改: