diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md index f65540a2a08e2feb53d4265e166d2ddefa4d617a..7ec01cd1c95acabd638e8f78acef211df9a65aee 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md @@ -1,7 +1,8 @@ # XComponent - > **说明:** - > 该组件从API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + > **说明:** + + > 该组件从API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 可用于EGL/OpenGLES和媒体数据写入,并显示在XComponent组件。 @@ -17,22 +18,34 @@ XComponent\(value: {id: string, type: string, libraryname?: string, controller?: XComponentController}\) - - 参数 - - | 名称 | 参数类型 | 必填 | 描述 | - | ----------- | ---------------------------------------- | ---- | ---------------------------------------- | - | id | string | 是 | 组件的唯一标识,支持最大的字符串长度128。 | - | type | string | 是 | 用于指定XComponent组件类型,可选值为:
-surface:组件内容单独送显,直接合成到屏幕。
-component:组件内容与其他组件合成后统一送显。 | - | libraryname | string | 否 | 应用Native层编译输出动态库名称。 | - | controller | [XComponentController](#XComponentController) | 否 | 给组件绑定一个控制器,通过控制器调用组件方法。 | +**参数:** +| 参数名 | 参数类型 | 必填 | 描述 | +| --------- | ------ | ---- | ----- | +| id | string | 是 | 组件的唯一标识,支持最大的字符串长度128。 | +| type | string | 是 | 用于指定XComponent组件类型,可选值为:
-surface:组件内容单独送显,直接合成到屏幕。
-component:组件内容与其他组件合成后统一送显。 | +| libraryname | string | 否 | 应用Native层编译输出动态库名称。 | +| controller | [XComponentcontroller](#xcomponentcontroller) | 否 | 给组件绑定一个控制器,通过控制器调用组件方法。 | ## 事件 -| 名称 | 功能描述 | -| -------------------------------- | ------------ | -| onLoad(context?: object) => void | 插件加载完成时回调事件。 | -| onDestroy() => void | 插件卸载完成时回调事件。 | +### onLoad + +onLoad(callback: (event?: object) => void ) + +插件加载完成时回调事件。 + +**参数:** + +| 参数名 | 参数类型 | 必填 | 描述 | +| ------------- | ------ | ---- | ----------------------- | +| event | object | 否 | 获取XComponent实例对象的context,context上挂载的方法由开发者在c++层定义。 | + +### onDestroy + +onDestroy(event: () => void ) + +插件卸载完成时回调事件。 ## XComponentController @@ -50,11 +63,13 @@ getXComponentSurfaceId(): string 获取XComponent对应Surface的ID,供@ohos接口使用,比如camera相关接口。 - - 返回值 +**系统接口:** 此接口为系统接口。 + +**返回值:** - | 类型 | 描述 | - | ------ | ----------------------- | - | string | XComponent持有Surface的ID。 | +| 类型 | 描述 | +| ------ | ----------------------- | +| string | XComponent持有Surface的ID。 | ### setXComponentSurfaceSize @@ -62,12 +77,14 @@ setXComponentSurfaceSize(value: {surfaceWidth: number, surfaceHeight: number}): 设置XComponent持有Surface的宽度和高度。 -- 参数 +**系统接口:** 此接口为系统接口。 - | 参数名 | 参数类型 | 必填 | 默认值 | 描述 | - | ------------- | ------ | ---- | ---- | ----------------------- | - | surfaceWidth | number | 是 | - | XComponent持有Surface的宽度。 | - | surfaceHeight | number | 是 | - | XComponent持有Surface的高度。 | +**参数:** + +| 参数名 | 参数类型 | 必填 | 描述 | +| ------------- | ------ | ---- | ----------------------- | +| surfaceWidth | number | 是 | XComponent持有Surface的宽度。 | +| surfaceHeight | number | 是 | XComponent持有Surface的高度。 | ### getXComponentContext @@ -75,16 +92,15 @@ getXComponentContext(): Object 获取XComponent实例对象的context。 -- 返回值 +**返回值:** - | 类型 | 描述 | - | ------ | ---------------------------------------- | - | Object | 获取XComponent实例对象的context,context包含的具体接口方法由开发者自定义。 | +| 类型 | 描述 | +| ------ | ---------------------------------------- | +| Object | 获取XComponent实例对象的context,context包含的具体接口方法由开发者自定义。 | ## 示例 提供surface类型XComponent,支持相机预览等能力。 - 示例效果请以真机运行为准,当前IDE预览器不支持。 ```ts @@ -116,4 +132,4 @@ struct PreviewArea { .position({x: 0, y: 48}) } } -``` \ No newline at end of file +```