From 04f1e181a581a4471727ab767dde4723dcfefc3d Mon Sep 17 00:00:00 2001 From: Charles Lo Date: Sat, 11 Aug 2018 18:27:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=20background:=20transparent=20?= =?UTF-8?q?=E5=80=BC=E5=81=9A=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E6=94=AF=E6=8C=81=E9=80=8F=E6=98=8E=E8=83=8C=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复指定 transparent 属性值会当做本地图片处理以至于出现 VM22878:2 Failed to load local image resource 的错误,已在背景填充颜色逻辑上对 transparent 做了特殊判断处理 --- lib/pen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pen.js b/lib/pen.js index 4a8c5fa..c4e803b 100644 --- a/lib/pen.js +++ b/lib/pen.js @@ -34,7 +34,7 @@ export default class Painter { // 如果未设置背景,则默认使用白色 this.ctx.setFillStyle('#fff'); this.ctx.fillRect(-(width / 2), -(height / 2), width, height); - } else if (bg.startsWith('#') || bg.startsWith('rgba')) { + } else if (bg.startsWith('#') || bg.startsWith('rgba') || bg.toLowerCase() === 'transparent') { // 背景填充颜色 this.ctx.setFillStyle(bg); this.ctx.fillRect(-(width / 2), -(height / 2), width, height);