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 047a241e3fba0b39c2b96c2926de053dd31f7772..a88519e059ad6602bea76946c85d4938ea21695a 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%')