docs/api/get-performance.md
返回一个Performance对象实例
| Web | 微信小程序 | Android | iOS | HarmonyOS | HarmonyOS(Vapor) |
|---|---|---|---|---|---|
| <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | 3.91 | 4.25 | 4.61 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
| 类型 |
|---|
| Performance |
createObserver 创建全局性能事件监听器
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | 4.41 | - | - | - |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| callback | (entries: PerformanceObserverEntryList) => void | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - |
getEntries 该方法返回当前列表中的所有性能数据
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | - | - | - | - |
| 类型 |
|---|
| Array<PerformanceEntry> |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| entryType | string | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 指标类型 |
| name | string | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 指标名称 |
| duration | number | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 耗时 ms。仅对于表示阶段的指标有效。 |
| startTime | number | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 开始时间,不同指标的具体含义会有差异。 |
| path | string | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 页面路径。仅 render 和 navigation 类型指标有效。 |
| referrerPath | string | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 页面跳转来源页面路径。仅 route 指标有效。 |
| pageId | number | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | path 对应页面实例 Id(随机生成,不保证递增)。仅 render/navigation 指标有效。 |
| referrerPageId | number | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | referrerPath对应页面实例 Id(随机生成,不保证递增)。仅 route 指标有效。 |
| navigationStart | number | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 路由真正响应开始时间。仅 navigation 类型指标有效。 |
| navigationType | string | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 路由详细类型,与路由方法对应。仅 navigation 类型指标有效。 |
| initDataRecvTime | number | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 首次渲染参数在渲染层收到的时间。仅 firstRender 指标有效。 |
| viewLayerRenderEndTime | number | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 渲染层执行渲染结束时间。仅 firstRender 指标有效。 |
getEntriesByType 获取当前列表中所有类型为 [entryType]的性能数据
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | - | - | - | - |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| entryType | string | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - |
| 类型 |
|---|
| Array<PerformanceEntry> |
getEntriesByName 获取当前列表中所有名称为 [name] 且类型为 [entryType]的性能数据
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | - | - | - | - |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| name | string | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | |
| entryType | string | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - |
| 类型 |
|---|
| Array<PerformanceEntry> |
| 类型 |
|---|
| PerformanceObserver |
observe 开始监听
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | - | - | - | - |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| options | PerformanceObserverOptions | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| buffered | boolean | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | |
| entryTypes | Array<string> | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | |
| type | string | 否 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - |
disconnect 停止监听
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | - | - | - | - |
getEntries 该方法返回当前缓冲区中的所有性能数据
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | 4.41 | - | - | - |
| 类型 |
|---|
| Array<PerformanceEntry> |
getEntriesByType 获取当前缓冲区中所有类型为 [entryType]的性能数据
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | 4.41 | - | - | - |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| entryType | string | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - |
| 类型 |
|---|
| Array<PerformanceEntry> |
getEntriesByName 获取当前缓冲区中所有名称为 [name] 且类型为 [entryType]的性能数据
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | 4.41 | - | - | - |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| name | string | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | |
| entryType | string | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - |
| 类型 |
|---|
| Array<PerformanceEntry> |
setBufferSize 设置缓冲区大小,默认缓冲 30 条性能数据
| Web | 微信小程序 | Android | iOS | HarmonyOS |
|---|---|---|---|---|
| x | 4.41 | - | - | - |
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| size | number | 是 | - | Web: x; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| errMsg | string | 是 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 错误信息 |