From d8b280949135fdef0dfb637d34ea3ed4e8b2559f Mon Sep 17 00:00:00 2001 From: elvinpeng Date: Sun, 29 Aug 2021 15:38:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20shouldClearRect=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E5=85=81=E8=AE=B8=E5=9C=A8=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E5=89=8D=E4=B8=8D=E6=B8=85=E7=A9=BA=20canvas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index ffa8834..5ca528e 100644 --- a/src/index.js +++ b/src/index.js @@ -47,7 +47,7 @@ Component({ }, methods: { async renderToCanvas(args) { - const {wxml, style} = args + const {wxml, style, shouldClearRect = true} = args const ctx = this.ctx const canvas = this.canvas const use2dCanvas = this.data.use2dCanvas @@ -56,7 +56,9 @@ Component({ return Promise.reject(new Error('renderToCanvas: fail canvas has not been created')) } - ctx.clearRect(0, 0, this.data.width, this.data.height) + if (shouldClearRect) { + ctx.clearRect(0, 0, this.data.width, this.data.height) + } const {root: xom} = xmlParse(wxml) const widget = new Widget(xom, style)