From 6c9abf6a53b5dfd2f6225643ae2eadf37a25a993 Mon Sep 17 00:00:00 2001 From: limeng Date: Tue, 16 May 2023 18:02:54 +0800 Subject: [PATCH] fix the problem of example. Signed-off-by: limeng --- .../reference/arkui-ts/ts-components-offscreencanvas.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-offscreencanvas.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-offscreencanvas.md index 047a241e3f..a88519e059 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-offscreencanvas.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-offscreencanvas.md @@ -120,6 +120,9 @@ struct OffscreenCanvasPage { .height('100%') .backgroundColor('#ffff00') .onReady(() => { + var offContext = this.offCanvas.getContext("2d", this.settings) + offContext.font = '70px sans-serif' + offContext.fillText("Offscreen : Hello World!", 20, 60) var imageData = this.offCanvas.transferToImageBitmap() this.context.transferFromImageBitmap(imageData) }) @@ -186,7 +189,7 @@ struct OffscreenCanvasExamplePage { offContext.stroke() offContext.fillStyle = '#FF00FF' offContext.fillRect(100, 100, 60, 60) - var imageData = offContext.transferToImageBitmap() + var imageData = this.offscreenCanvas.transferToImageBitmap() this.context.transferFromImageBitmap(imageData) }) }.width('100%').height('100%') -- GitLab