提交 8c757333 编写于 作者: E ester.zhou

update docs (7182)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 9b68e00c
...@@ -24,62 +24,24 @@ Text(content?: string) ...@@ -24,62 +24,24 @@ Text(content?: string)
- Parameters - Parameters
| Name| Type| Mandatory| Default Value| Description| | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| content | string | No| '' | Text content. This parameter does not take effect when the child component **\<Span>** is contained.| | content | string | No| '' | Text content. The content and style set for the **\<Text>** component do not take effect when it contains the **\<Span>** child component.|
## Attributes ## Attributes
| Name| Type| Default Value| Description| | Name| Type| Default Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| textAlign | TextAlign | TextAlign.Start | Text alignment mode of multiple lines of text.| | textAlign | [TextAlign](ts-appendix-enums.md) | TextAlign.Start | Text alignment mode of multiple lines of text.|
| textOverflow | {overflow: TextOverflow} | {overflow: TextOverflow.Clip} | Display mode when the text is too long.<br>**NOTE**<br/><br>Text is truncated at the transition between words. To truncate text in the middle of a word, add **\u200B** between characters.<br>This attribute must be used with `maxLines` to take effect.| | textOverflow | {overflow:&nbsp;[TextOverflow](ts-appendix-enums.md)} | {overflow:&nbsp;TextOverflow.Clip} | Display mode when the text is too long.<br>**NOTE**<br/><br>Text is truncated at the transition between words. To truncate text in the middle of a word, add **\u200B** between characters.<br>This attribute must be used with `maxLines` to take effect.|
| maxLines | number | Infinity | Maximum number of lines in the text.<br>**NOTE**<br/><br>By default, text is automatically folded. If this parameter is specified, the text does not exceed the specified number of lines. If there is extra text, you can use `textOverflow` to specify the truncation mode.| | maxLines | number | Infinity | Maximum number of lines in the text.<br>**NOTE**<br/><br>By default, text is automatically folded. If this parameter is specified, the text does not exceed the specified number of lines. If there is extra text, you can use `textOverflow` to specify the truncation mode.|
| lineHeight | Length | - | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.| | lineHeight | Length | - | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.|
| decoration | {<br>type: TextDecorationType,<br>color?: Color<br>} | {<br>type: TextDecorationType.None,<br>color: Color.Black<br>} | Style and color of the text decorative line.| | decoration | {<br>type:&nbsp;[TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br>color?:&nbsp;Color<br>} | {<br>type:&nbsp;TextDecorationType.None,<br>color: Color.Black<br>} | Style and color of the text decorative line.|
| baselineOffset | Length | - | Offset of the text baseline.| | baselineOffset | Length | - | Offset of the text baseline.|
| textCase | TextCase | TextCase.Normal | Text case.| | textCase | [TextCase](ts-appendix-enums.md#textcase) | TextCase.Normal | Text case.|
| copyOption<sup>9+</sup> | boolean\|CopyOption | false | Whether copy and paste is allowed.| | copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md) | CopyOptions.None | Whether copy and paste is allowed.|
- TextAlign enums > **NOTE**<br/>
| Name| Description| > The **\<Text>** component cannot contain both the text and the child component **\<Span>**. If both of them exist, only the content in **\<Span>** is displayed.
| -------- | -------- |
| Center | The text is center-aligned.|
| Start | The text is aligned with the direction in which the text is written.|
| End | The text is aligned with the opposite direction in which the text is written.|
- TextOverflow enums
| Name| Description|
| -------- | -------- |
| Clip | Extra text is truncated.|
| Ellipsis | An ellipsis (...) is used to represent clipped text.|
| None | No truncation or ellipsis is used for extra-long text.|
- TextDecorationType enums
| Name| Description|
| -------- | -------- |
| Underline | Line under the text.|
| LineThrough | Line through the text.|
| Overline | Line over the text.|
| None | No decorative lines.|
- TextCase enums
| Name | Description |
| --------- | -------------------- |
| Normal | The original case of the text is retained.|
| LowerCase | All letters in the text are in lowercase. |
| UpperCase | All letters in the text are in uppercase. |
- CopyOption<sup>9+</sup> enums
| Name| Description|
| -------- | -------- |
| InApp | Intra-application copy and paste is allowed.|
| LocalDevice | Intra-device copy and paste is allowed.|
| CrossDevice | Cross-device copy and paste is allowed.|
> **NOTE**<br/>
> If the **\<Text>** component contains both the text and the **\<Span>** child component, only the content in **\<Span>** is displayed.
## Example ## Example
......
# CanvasRenderingContext2D # CanvasRenderingContext2D
> **NOTE**<br>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
The **\<RenderingContext>** component is used to draw rectangles, text, images, and other objects on a canvas. The **\<RenderingContext>** component is used to draw rectangles, text, images, and other objects on a canvas.
> **NOTE**
>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
## APIs ## APIs
...@@ -259,7 +258,7 @@ struct MiterLimit { ...@@ -259,7 +258,7 @@ struct MiterLimit {
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct Font { struct Fonts {
private settings: RenderingContextSettings = new RenderingContextSettings(true) private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
...@@ -1282,7 +1281,8 @@ Draws an arc on the canvas. ...@@ -1282,7 +1281,8 @@ Draws an arc on the canvas.
- Example - Example
``` ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct Arc { struct Arc {
......
# Combined Gestures # Combined Gestures
Continuous recognition, parallel recognition, and exclusive recognition are supported for a group of gestures.
> **NOTE**<br> > **NOTE**
>
> Combined gestures are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > Combined gestures are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -21,37 +23,38 @@ GestureGroup(mode: GestureMode, ...gesture: GestureType[]) ...@@ -21,37 +23,38 @@ GestureGroup(mode: GestureMode, ...gesture: GestureType[])
| gesture | [TapGesture](ts-basic-gestures-tapgesture.md)<br/>\| [LongPressGesture](ts-basic-gestures-longpressgesture.md)<br/>\| [PanGesture](ts-basic-gestures-pangesture.md)<br/>\| [PinchGesture](ts-basic-gestures-pinchgesture.md)<br/>\| [RotationGesture](ts-basic-gestures-rotationgesture.md) | Yes | - | Variable-length parameter, indicating one or more basic gesture types. These gestures are recognized in combination. | | gesture | [TapGesture](ts-basic-gestures-tapgesture.md)<br/>\| [LongPressGesture](ts-basic-gestures-longpressgesture.md)<br/>\| [PanGesture](ts-basic-gestures-pangesture.md)<br/>\| [PinchGesture](ts-basic-gestures-pinchgesture.md)<br/>\| [RotationGesture](ts-basic-gestures-rotationgesture.md) | Yes | - | Variable-length parameter, indicating one or more basic gesture types. These gestures are recognized in combination. |
- GestureMode enums - GestureMode enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| Sequence | Sequential recognition: Gestures are recognized in the registration sequence until all gestures are recognized successfully. When one gesture fails to be recognized, all gestures fail to be recognized. | | Sequence | Sequential recognition: Gestures are recognized in the registration sequence until all gestures are recognized successfully. When one gesture fails to be recognized, all gestures fail to be recognized. |
| Parallel | Parallel recognition. Registered gestures are recognized concurrently until all gestures are recognized. The recognition result of each gesture does not affect each other. | | Parallel | Parallel recognition. Registered gestures are recognized concurrently until all gestures are recognized. The recognition result of each gesture does not affect each other. |
| Exclusive | Exclusive recognition. Registered gestures are identified concurrently. If one gesture is successfully recognized, gesture recognition ends. | | Exclusive | Exclusive recognition. Registered gestures are identified concurrently. If one gesture is successfully recognized, gesture recognition ends. |
## Events ## Events
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| onCancel(event: () =&gt; void) | Callback for the GestureMode.Sequence cancellation event. | | onCancel(event: () =&gt; void) | Callback for the GestureMode.Sequence cancellation event. |
## Example ## Example
``` ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct GestureGroupExample { struct GestureGroupExample {
@State count: number = 0 @State count: number = 0
@State offsetX: number = 0 @State offsetX: number = 0
@State offsetY: number = 0 @State offsetY: number = 0
@State borderStyle: BorderStyle = BorderStyle.Solid @State borderStyles: BorderStyle = BorderStyle.Solid
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('sequence gesture\n' + 'LongPress onAction:' + this.count + '\nPanGesture offset:\nX: ' + this.offsetX + '\n' + 'Y: ' + this.offsetY) Text('sequence gesture\n' + 'LongPress onAction:' + this.count + '\nPanGesture offset:\nX: ' + this.offsetX + '\n' + 'Y: ' + this.offsetY)
}.translate({ x: this.offsetX, y: this.offsetY, z: 5 }) }.translate({ x: this.offsetX, y: this.offsetY, z: 5 })
.height(100).width(200).padding(10).margin(80).border({ width: 1, style: this.borderStyle }) .height(100).width(200).padding(10).margin(80).border({ width: 1, style: this.borderStyles })
.gesture( .gesture(
GestureGroup(GestureMode.Sequence, GestureGroup(GestureMode.Sequence,
LongPressGesture({ repeat: true }) LongPressGesture({ repeat: true })
...@@ -64,7 +67,7 @@ struct GestureGroupExample { ...@@ -64,7 +67,7 @@ struct GestureGroupExample {
}), }),
PanGesture({}) PanGesture({})
.onActionStart(() => { .onActionStart(() => {
this.borderStyle = BorderStyle.Dashed this.borderStyles = BorderStyle.Dashed
console.log('pan start') console.log('pan start')
}) })
.onActionUpdate((event: GestureEvent) => { .onActionUpdate((event: GestureEvent) => {
......
# Page Transition # Page Transition
> **NOTE**<br>
> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
Customize the page transition animations by configuring the page entrance and exit components in the global **pageTransition** method. Customize the page transition animations by configuring the page entrance and exit components in the global **pageTransition** method.
## APIs > **NOTE**
>
> This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
| Name | Parameter | Description | | Name | Parameter | Description |
| -------- | -------- | -------- | | ------------------- | ------ | ------------------------------- |
| PageTransitionEnter | Object | Page entrance component, which is used to customize the entrance effect of the current page. For details, see animation parameters. | | PageTransitionEnter | Object | Page entrance component, which is used to customize the entrance effect of the current page. For details, see animation parameters.|
| PageTransitionExit | Object | Page exit component, which is used to customize the exit effect of the current page. For details, see animation parameters. | | PageTransitionExit | Object | Page exit component, which is used to customize the exit effect of the current page. For details, see animation parameters.|
- Animation parameters - Animation parameters
| Name | Type | Default Value | Mandatory | Description | | Name | Type | Default Value | Mandatory | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | ------------------------- | ------ | ---- | ---------------------------------------- |
| type | RouteType | - | No | If this parameter is not set, the reverse playback effect as pop switches to push is used. | | type | RouteType | - | No | Animation type. If this parameter is not set, the reverse playback effect as **pop** switches to **push** is used. |
| duration | number | 1000 | No | Animation duration, in ms. | | duration | number | 1000 | No | Animation duration, in ms. |
| curve | Curve \| Curves | Linear | No | Animation curve. For details about the valid values, see **Curve enums**. | | curve | Curve&nbsp;\|&nbsp;Curves | Linear | No | Animation curve. For details about the valid values, see [Curve](ts-animatorproperty.md).|
| delay | number | 0 | No | Animation delay, in ms. Delayed animation is disabled by default. | | delay | number | 0 | No | Animation delay, in ms. Delayed animation is disabled by default. |
- RouteType enums - RouteType enums
| Name | Description | | Name| Description |
| -------- | -------- | | ---- | ---------------- |
| Pop | When page A jumps to page B, page A is Exit+Push, and page B is Enter+Push. | | Pop | Redirects to a specified page.|
| Push | When page B returns to page A, page A is Enter+Pop, and page B is Exit+Pop. | | Push | Redirects to the next page.|
## Attributes ## Attributes
The **PageTransitionEnter** and **PageTransitionExit** components support the following attributes: The **PageTransitionEnter** and **PageTransitionExit** parameters support the following attributes:
| Name | Type | Default Value | Mandatory | Description | | Name | Type | Default Value | Mandatory | Description |
| -------- | -------- | -------- | -------- | -------- | | --------- | ---------------------------------------- | ----------------- | ---- | ---------------------------------------- |
| slide | SlideEffect | SlideEffect.Right | No | Slide effect during page transition. For details about the valid values, see **SlideEffect enums**. | | slide | SlideEffect | SlideEffect.Right | No | Slide effect during page transition. For details about the valid values, see **SlideEffect** enums. |
| translate | {<br/>x? : number,<br/>y? : number,<br/>z? : number<br/>} | - | No | Translation effect during page transition, which is the value of the start point of entrance and the end point of exit. When this parameter is set together with **slide**, the latter takes effect by default. | | translate | {<br>x?&nbsp;:&nbsp;number,<br>y?&nbsp;:&nbsp;number,<br>z?&nbsp;:&nbsp;number<br>} | - | No | Translation effect during page transition, which is the value of the start point of entrance and the end point of exit. When this parameter is set together with **slide**, the latter takes effect by default.|
| scale | {<br/>x? : number,<br/>y? : number,<br/>z? : number,<br/>centerX? : number,<br/>centerY? : number<br/>} | - | No | Scaling effect during page transition, which is the value of the start point of entrance and the end point of exit. | | scale | {<br>x?&nbsp;:&nbsp;number,<br>y?&nbsp;:&nbsp;number,<br>z?&nbsp;:&nbsp;number,<br>centerX?&nbsp;:&nbsp;number,<br>centerY?&nbsp;:&nbsp;number<br>} | - | No | Scaling effect during page transition, which is the value of the start point of entrance and the end point of exit. |
| opacity | number | 1 | No | Opacity, which is the opacity value of the start point of entrance or the end point of exit. | | opacity | number | 1 | No | Opacity, which is the opacity value of the start point of entrance or the end point of exit. |
- SlideEffect enums - SlideEffect enums
| Name | Description | | Name | Description |
| -------- | -------- | | ------ | ------------------------- |
| Left | When set to Enter, slides in from the left. When set to Exit, slides out to the left. | | Left | When set to Enter, slides in from the left. When set to Exit, slides out to the left.|
| Right | When set to Enter, slides in from the right. When set to Exit, slides out to the right. | | Right | When set to Enter, slides in from the right. When set to Exit, slides out to the right.|
| Top | When set to Enter, slides in from the top. When set to Exit, slides out to the top. | | Top | When set to Enter, slides in from the top. When set to Exit, slides out to the top.|
| Bottom | When set to Enter, slides in from the bottom. When set to Exit, slides out to the bottom. | | Bottom | When set to Enter, slides in from the bottom. When set to Exit, slides out to the bottom.|
## Events ## Events
The PageTransitionEnter and PageTransitionExit components support the following events: The **PageTransitionEnter** and **PageTransitionExit** parameters support the following events:
| Event | Description | | Name | Description |
| -------- | -------- | | ---------------------------------------- | ----------------------------------- |
| onEnter(type: RouteType, progress: number) =&gt; void | Callback invoked when page entrance occurs. The input parameter is the normalized progress of the current entrance animation. The value range is 0–1. | | onEnter(type:&nbsp;RouteType,&nbsp;progress:&nbsp;number)&nbsp;=&gt;&nbsp;void | The callback input parameter is the normalized progress of the current entrance animation. The value range is 0–1.|
| onExit(type: RouteType, progress: number) =&gt; void | Callback invoked when page exit occurs. The input parameter is the normalized progress of the current exit animation. The value range is 0–1. | | onExit(type:&nbsp;RouteType,&nbsp;progress:&nbsp;number)&nbsp;=&gt;&nbsp;void | The callback input parameter is the normalized progress of the current exit animation. The value range is 0–1.|
## Example ## Example
Customization method 1: The entrance animation of the current page is configured as fade-in, and the exit animation is configured as zoom-out. Customization method 1: The entrance animation of the current page is configured as fade-in, and the exit animation is configured as zoom-out.
```ts
```
// index.ets // index.ets
@Entry @Entry
@Component @Component
struct PageTransitionExample1 { struct PageTransitionExample1 {
@State scale: number = 1 @State scale1: number = 1
@State opacity: number = 1 @State opacity1: number = 1
@State active: boolean = false @State active: boolean = false
build() { build() {
Column() { Column() {
Navigator({ target: 'pages/page1', type: NavigationType.Push }) { Navigator({ target: 'pages/page1', type: NavigationType.Push }) {
...@@ -82,52 +80,52 @@ struct PageTransitionExample1 { ...@@ -82,52 +80,52 @@ struct PageTransitionExample1 {
.onClick(() => { .onClick(() => {
this.active = true this.active = true
}) })
}.scale({ x: this.scale }).opacity(this.opacity) }.scale({ x: this.scale1 }).opacity(this.opacity1)
} }
// Customization method 1: Customize the transition process. // Customization method 1: Customize the transition process.
pageTransition() { pageTransition() {
PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) PageTransitionEnter({ duration: 1200, curve: Curve.Linear })
.onEnter((type: RouteType, progress: number) => { .onEnter((type: RouteType, progress: number) => {
this.scale = 1 this.scale1 = 1
this.opacity = progress this.opacity1 = progress
}) // The onEnter callback is triggered frame by frame during the entrance process. The input parameter is the normalized progress of the animation (0% to 100%). }) // The onEnter callback is triggered frame by frame during the entrance process. The input parameter is the normalized progress of the animation (0% to 100%).
PageTransitionExit({ duration: 1500, curve: Curve.Ease }) PageTransitionExit({ duration: 1500, curve: Curve.Ease })
.onExit((type: RouteType, progress: number) => { .onExit((type: RouteType, progress: number) => {
this.scale = 1 - progress this.scale1 = 1 - progress
this.opacity = 1 this.opacity1 = 1
}) // The onExit callback is triggered frame by frame during the exit process. The input parameter is the normalized progress of the animation (0% to 100%). }) // The onExit callback is triggered frame by frame during the exit process. The input parameter is the normalized progress of the animation (0% to 100%).
} }
} }
``` ```
```ts
```
// page1.ets // page1.ets
@Entry @Entry
@Component @Component
struct AExample { struct AExample {
@State scale: number = 1 @State scale2: number = 1
@State opacity: number = 1 @State opacity2: number = 1
@State active: boolean = false @State active: boolean = false
build() { build() {
Column() { Column() {
Navigator({ target: 'pages/index' ,type: NavigationType.Push}) { Navigator({ target: 'pages/index' ,type: NavigationType.Push}) {
Image($r('app.media.bg2')).width("100%").height("100%") Image($r('app.media.bg2')).width("100%").height("100%")
} }
}.height("100%").width("100%").scale({ x: this.scale }).opacity(this.opacity) }.height("100%").width("100%").scale({ x: this.scale2 }).opacity(this.opacity2)
} }
// Customization method 1: Customize the transition process. // Customization method 1: Customize the transition process.
pageTransition() { pageTransition() {
PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) PageTransitionEnter({ duration: 1200, curve: Curve.Linear })
.onEnter((type: RouteType, progress: number) => { .onEnter((type: RouteType, progress: number) => {
this.scale = 1 this.scale2 = 1
this.opacity = progress this.opacity2 = progress
}) // The onEnter callback is triggered frame by frame during the entrance process. The input parameter is the normalized progress of the animation (0% to 100%). }) // The onEnter callback is triggered frame by frame during the entrance process. The input parameter is the normalized progress of the animation (0% to 100%).
PageTransitionExit({ duration: 1500, curve: Curve.Ease }) PageTransitionExit({ duration: 1500, curve: Curve.Ease })
.onExit((type: RouteType, progress: number) => { .onExit((type: RouteType, progress: number) => {
this.scale = 1 - progress this.scale2 = 1 - progress
this.opacity = 1 this.opacity2 = 1
}) // The onExit callback is triggered frame by frame during the exi process. The input parameter is the normalized progress of the animation (0% to 100%). }) // The onExit callback is triggered frame by frame during the exit process. The input parameter is the normalized progress of the animation (0% to 100%).
} }
} }
``` ```
...@@ -136,14 +134,13 @@ struct AExample { ...@@ -136,14 +134,13 @@ struct AExample {
Customization method 2: The entrance animation of the current page is configured to slide in from the left, and the exit animation is configured to zoom out with opacity change. Customization method 2: The entrance animation of the current page is configured to slide in from the left, and the exit animation is configured to zoom out with opacity change.
```ts
```
// index.ets // index.ets
@Entry @Entry
@Component @Component
struct PageTransitionExample { struct PageTransitionExample {
@State scale: number = 1 @State scale1: number = 1
@State opacity: number = 1 @State opacity1: number = 1
@State active: boolean = false @State active: boolean = false
build() { build() {
...@@ -154,7 +151,7 @@ struct PageTransitionExample { ...@@ -154,7 +151,7 @@ struct PageTransitionExample {
.onClick(() => { .onClick(() => {
this.active = true this.active = true
}) })
}.scale({ x: this.scale }).opacity(this.opacity) }.scale({ x: this.scale1 }).opacity(this.opacity1)
} }
// Customization method 2: Use the default effects provided by the system, such as translation, scaling, and opacity. // Customization method 2: Use the default effects provided by the system, such as translation, scaling, and opacity.
...@@ -168,14 +165,13 @@ struct PageTransitionExample { ...@@ -168,14 +165,13 @@ struct PageTransitionExample {
} }
``` ```
```ts
```
// page1.ets // page1.ets
@Entry @Entry
@Component @Component
struct PageTransitionExample1 { struct PageTransitionExample1 {
@State scale: number = 1 @State scale2: number = 1
@State opacity: number = 1 @State opacity2: number = 1
@State active: boolean = false @State active: boolean = false
build() { build() {
...@@ -186,7 +182,7 @@ struct PageTransitionExample1 { ...@@ -186,7 +182,7 @@ struct PageTransitionExample1 {
.onClick(() => { .onClick(() => {
this.active = true this.active = true
}) })
}.scale({ x: this.scale }).opacity(this.opacity) }.scale({ x: this.scale2 }).opacity(this.opacity2)
} }
// Customization method 2: Use the default effects provided by the system, such as translation, scaling, and opacity. // Customization method 2: Use the default effects provided by the system, such as translation, scaling, and opacity.
......
...@@ -63,7 +63,7 @@ struct Index { ...@@ -63,7 +63,7 @@ struct Index {
} }
``` ```
![zh-cn_image_borderImage](figures/borderImage.png) ![en-us_image_borderImage](figures/borderImage.png)
```ts ```ts
......
# Component Area Change Event # Component Area Change Event
The area change event is triggered when the component's size, position, or any other attribute that may affect its display area changes.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -12,20 +14,21 @@ None ...@@ -12,20 +14,21 @@ None
## Events ## Events
| Name | Bubble Supported | Description | | Name | Bubble Supported | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| onAreaChange(event: (oldValue: Area, newValue: Area) =&gt; void) | No | Triggered when the component area changes. For details about the **Area** type, see **Area** attributes. | | onAreaChange(event: (oldValue: Area, newValue: Area) =&gt; void) | No | Triggered when the component area changes. For details about the **Area** type, see **Area** attributes. |
## Example ## Example
``` ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct AreaExample { struct AreaExample {
@State value: string = 'Text' @State value: string = 'Text'
@State size: string = '' @State size1: string = ''
build() { build() {
Column() { Column() {
...@@ -36,7 +39,7 @@ struct AreaExample { ...@@ -36,7 +39,7 @@ struct AreaExample {
}) })
.onAreaChange((oldValue: Area, newValue: Area) => { .onAreaChange((oldValue: Area, newValue: Area) => {
console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} value is ${JSON.stringify(newValue)}`) console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} value is ${JSON.stringify(newValue)}`)
this.size = JSON.stringify(newValue) this.size1 = JSON.stringify(newValue)
}) })
Text('new area is: \n' + this.size).margin({ right: 30, left: 30 }) Text('new area is: \n' + this.size).margin({ right: 30, left: 30 })
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册