diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-arkui.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-arkui.md index acae7487a62c3d5b59229e2887a268959cd3439a..14f5001661951847a27501970666cc964641325d 100644 --- a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-arkui.md +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/changelogs-arkui.md @@ -77,4 +77,70 @@ struct ListExample { .padding({ top: 5 }) } } -``` \ No newline at end of file +``` +## 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及以后不会触发。 diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/figures/api10onReady.gif b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/figures/api10onReady.gif new file mode 100755 index 0000000000000000000000000000000000000000..5c0cb27ddf42514e174f1cabb9890aee792a96b6 Binary files /dev/null and b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/figures/api10onReady.gif differ diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/figures/api9onReady.gif b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/figures/api9onReady.gif new file mode 100755 index 0000000000000000000000000000000000000000..619d0a18ff2c73359f7d487b86aca147cd9d7f66 Binary files /dev/null and b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.9.2/figures/api9onReady.gif differ