未验证 提交 834f38c6 编写于 作者: O openharmony_ci 提交者: Gitee

!15260 【3.2-Beta5】翻译完成 14788:新增FormComponent文档说明

Merge pull request !15260 from ester.zhou/C05-14788
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
- [DataPanel](ts-basic-components-datapanel.md) - [DataPanel](ts-basic-components-datapanel.md)
- [DatePicker](ts-basic-components-datepicker.md) - [DatePicker](ts-basic-components-datepicker.md)
- [Divider](ts-basic-components-divider.md) - [Divider](ts-basic-components-divider.md)
- [Formcomponent](ts-basic-components-formcomponent.md)
- [Gauge](ts-basic-components-gauge.md) - [Gauge](ts-basic-components-gauge.md)
- [Image](ts-basic-components-image.md) - [Image](ts-basic-components-image.md)
- [ImageAnimator](ts-basic-components-imageanimator.md) - [ImageAnimator](ts-basic-components-imageanimator.md)
...@@ -101,7 +102,6 @@ ...@@ -101,7 +102,6 @@
- [ColumnSplit](ts-container-columnsplit.md) - [ColumnSplit](ts-container-columnsplit.md)
- [Counter](ts-container-counter.md) - [Counter](ts-container-counter.md)
- [Flex](ts-container-flex.md) - [Flex](ts-container-flex.md)
- [FlowItem](ts-container-flowitem.md)
- [GridCol](ts-container-gridcol.md) - [GridCol](ts-container-gridcol.md)
- [GridRow](ts-container-gridrow.md) - [GridRow](ts-container-gridrow.md)
- [Grid](ts-container-grid.md) - [Grid](ts-container-grid.md)
...@@ -121,7 +121,6 @@ ...@@ -121,7 +121,6 @@
- [Swiper](ts-container-swiper.md) - [Swiper](ts-container-swiper.md)
- [Tabs](ts-container-tabs.md) - [Tabs](ts-container-tabs.md)
- [TabContent](ts-container-tabcontent.md) - [TabContent](ts-container-tabcontent.md)
- [WaterFlow](ts-container-waterflow.md)
- Media Components - Media Components
- [Video](ts-media-components-video.md) - [Video](ts-media-components-video.md)
- Drawing Components - Drawing Components
......
# FormComponent
The **FormComponent** is used to display widgets.
> **NOTE**
>
> - This component is supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - This component is intended for the widget host. For details about the widget provider, see [JS Service Widget UI Components](../js-service-widget-ui/Readme-EN.md).
>
> - To use this component, you must have the system signature.
## Required Permissions
ohos.permission.GET_BUNDLE_INFO
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
ohos.permission.REQUIRE_FORM
## Child Components
Not supported
## APIs
FormComponent(value: {
id: number;
name: string;
bundle: string;
ability: string;
module: string;
dimension?: FormDimension;
temporary?: boolean
})
Creates a **FormComponent** instance to display the provided widget.
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ----------------------------------------------------------------------- |
| id | number | Yes | Widget ID. Set this parameter to **0** for a new widget. |
| name | string | Yes | Widget name. |
| bundle | string | Yes | Bundle name of the widget. |
| ability | string | Yes | Ability name of the widget. |
| module | string | Yes | Module name of the widget. |
| dimension | [FormDimension](#formdimension) | No | Dimensions of the widget. The widgets in the 2 x 2, 4 x 4, and 4 x 2 dimensions are supported.<br>Default value: **Dimension_2_2**|
| temporary | boolean | No | Whether the widget is a temporary one. |
## FormDimension
| Name | Description |
| -------------------------- | -------- |
| Dimension_1_2 | 1 x 2 widget.|
| Dimension_2_2 | 2 x 2 widget.|
| Dimension_2_4 | 2 x 4 widget.|
| Dimension_4_4 | 4 x 4 widget.|
| Dimension_2_1<sup>9+</sup> | 2 x 1 widget.|
## Attributes
| Name | Type | Mandatory| Description |
| ----------- | ----------------------------------------------------------------------------------------------------- | ---- | ----------------------------------------------------------------------- |
| size | {<br>width?:&nbsp;[Length](ts-types.md#length),<br>height?:&nbsp;[Length](ts-types.md#length)<br>} | Yes | Size of the widget. |
| moduleName | string | Yes | Module name of the widget. |
| dimension | [FormDimension](#formdimension) | No | Dimensions of the widget. The widgets in the 2 x 2, 4 x 4, and 4 x 2 dimensions are supported.<br>Default value: **Dimension_2_2**|
| allowUpdate | boolean | No | Whether to allow the widget to update.<br>Default value: **true** |
| visibility | [Visibility](ts-appendix-enums.md#visibility) | No | Whether the widget is visible.<br>Default value: **Visible** |
## Events
| Name | Description |
| ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| onAcquired(callback:&nbsp;(info:&nbsp;{&nbsp;id:&nbsp;number&nbsp;})&nbsp;=&gt;&nbsp;void) | Triggered when a widget is obtained. This API returns the ID of the obtained widget. |
| onError(callback:&nbsp;(info:&nbsp;{&nbsp;errcode:&nbsp;number,&nbsp;msg:&nbsp;string&nbsp;})&nbsp;=&gt;&nbsp;void) | Triggered when an error occurs during component loading.<br>**errcode**: error code.<br>**msg**: error information. |
| onRouter(callback:&nbsp;(info:&nbsp;any)&nbsp;=&gt;&nbsp;void) | Triggered when routing occurs for the widget. This API returns information in [routerEvent](../js-service-widget-ui/js-service-widget-syntax-hml.md#event-binding).|
| onUninstall(callback:&nbsp;(info:&nbsp;{&nbsp;id:&nbsp;number&nbsp;})&nbsp;=&gt;&nbsp;void) | Triggered when a widget is uninstalled. This API returns the ID of the uninstalled widget. |
## Example
```ts
//card.ets
@Entry
@Component
struct CardExample {
@State formId:number = 0;
build() {
Column() {
Text('this is a card')
.fontSize(50)
.fontWeight(FontWeight.Bold)
FormComponent({
id:this.formId,
name:"Form1",
bundle:"com.example.cardexample",
ability:"FormAbility",
module:"entry",
dimension:FormDimension.Dimension_2_2,
temporary:false
})
.allowUpdate(true)
.size({width:360,height:360})
.visibility(Visibility.Visible)
.onAcquired((form)=>{
console.log(`form info : ${JSON.stringify(form)}`);
this.fomId = form.id;
})
.onError((err)=>{
console.log(`fail to add form, err: ${JSON.stringify(err)}`);
})
}
.width('100%')
.height('100%')
}
}
```
![Form](figures/form.png)
...@@ -69,12 +69,6 @@ ...@@ -69,12 +69,6 @@
- [Swiper](ts-container-swiper.md) - [Swiper](ts-container-swiper.md)
A container that is able to display child components in looping mode. A container that is able to display child components in looping mode.
- [WaterFlow](ts-container-waterflow.md)
A container that consists of cells formed by rows and columns and arranges items of different sizes from top to bottom according to the preset rules.
- [FlowItem](ts-container-flowitem.md)
A child component of the **\<WaterFlow>** container that is used to display specific items in the container layout.
## Navigation ## Navigation
...@@ -288,3 +282,6 @@ ...@@ -288,3 +282,6 @@
- [RemoteWindow](ts-basic-components-remotewindow.md) - [RemoteWindow](ts-basic-components-remotewindow.md)
A component that is used to control the application window, providing the component animator and application window linkage animator during application startup and exit. A component that is used to control the application window, providing the component animator and application window linkage animator during application startup and exit.
- [Formcomponent](ts-basic-components-formcomponent.md)
A component that is used to display widgets.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册