提交 db6fd591 编写于 作者: L lilanqing

onready changelog

Signed-off-by: Nlilanqing <lilanqing@huawei.com>
Change-Id: Ibd6ee164ccdc2cca1e6bb604ef515edf2479b23d
上级 acde4c15
......@@ -77,70 +77,4 @@ struct ListExample {
.padding({ top: 5 })
}
}
```
## cl.arkui.2 canvas组件onReady事件行为变更
**说明**
onReady事件在组件创建完成后或组件大小发生变化时触发,并清空画布。
**示例:**
```ts
@Entry
@Component
struct OnReadyDiff {
@State message: string = 'init '
@State isShow: boolean = false
@State myHeight: number = 300
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button('ChangePosition')
.onClick(()=>{
this.isShow = !this.isShow
})
if (this.isShow) {
Button('new button')
.height(200)
}
Button('ChangeHeight')
.onClick(()=>{
this.myHeight = this.myHeight==300?500:300
})
Canvas(this.context)
.width(300)
.height(this.myHeight)
.backgroundColor('#ffff00')
.onReady(() =>{
this.context.fillRect(0, 0, 100, 100)
this.message += 'a '
})
Button('draw another')
.onClick(()=>{
this.context.fillRect(100, 100, 100, 100)
})
}
.width('100%')
}
.height('100%')
}
}
```
API version 9:onReady在组件创建完成时触发,位置变化时会触发,组件大小变化时也会触发。
![stack](figures/api9onReady.gif)
API version 10及以后:onReady在组件创建完成时触发,在组件位置变化时不会触发,组件大小变化时会触发。
![stack](figures/api10onReady.gif)
**变更影响**
onReady事件在组件位置发生变化时行为变更,API version 9及以前会触发,API version 10及以后不会触发。
```
\ No newline at end of file
......@@ -161,3 +161,69 @@ struct Child {
}
}
```
## cl.arkui.3 canvas组件onReady事件行为变更
**说明**
onReady事件在组件创建完成后或组件大小发生变化时触发,并清空画布。
**示例:**
```ts
@Entry
@Component
struct OnReadyDiff {
@State message: string = 'init '
@State isShow: boolean = false
@State myHeight: number = 300
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button('ChangePosition')
.onClick(()=>{
this.isShow = !this.isShow
})
if (this.isShow) {
Button('new button')
.height(200)
}
Button('ChangeHeight')
.onClick(()=>{
this.myHeight = this.myHeight==300?500:300
})
Canvas(this.context)
.width(300)
.height(this.myHeight)
.backgroundColor('#ffff00')
.onReady(() =>{
this.context.fillRect(0, 0, 100, 100)
this.message += 'a '
})
Button('draw another')
.onClick(()=>{
this.context.fillRect(100, 100, 100, 100)
})
}
.width('100%')
}
.height('100%')
}
}
```
API version 9:onReady在组件创建完成时触发,位置变化时会触发,组件大小变化时也会触发。
![stack](figures/api9onReady.gif)
API version 10及以后:onReady在组件创建完成时触发,在组件位置变化时不会触发,组件大小变化时会触发。
![stack](figures/api10onReady.gif)
**变更影响**
onReady事件在组件位置发生变化时行为变更,API version 9及以前会触发,API version 10及以后不会触发。
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册