From c3fcefb6806f23b9061f5899c6d13fa371581c30 Mon Sep 17 00:00:00 2001 From: hdx Date: Tue, 26 Nov 2024 18:41:07 +0800 Subject: [PATCH] =?UTF-8?q?canvas:=20=E8=B0=83=E6=95=B4=20toDataURL=20?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/canvas/canvas.uvue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pages/component/canvas/canvas.uvue b/pages/component/canvas/canvas.uvue index 624e130f..28deb645 100644 --- a/pages/component/canvas/canvas.uvue +++ b/pages/component/canvas/canvas.uvue @@ -94,16 +94,18 @@ // #ifdef WEB context.toBlob((blob : Blob) => { this.testToBlobResult = (blob.size > 0 && blob.type == 'image/jpeg') - }, 'image/jpeg', 0.95) + }, 'image/jpeg', 0.95); + this.testToDataURLResult = this.canvasContext!.toDataURL().startsWith('data:image/png;base64') // #endif - this.testCanvasContext = true } }) }, onReady() { // TODO app-android 需要延迟调用 + // #ifdef APP this.testToDataURLResult = this.canvasContext!.toDataURL().startsWith('data:image/png;base64') + // #endif // 同步调用方式,仅支持 app/web // let canvas = uni.getElementById("canvas") as UniCanvasElement -- GitLab