diff --git a/components-diy/diy-recommend-code.vue b/components-diy/diy-recommend-code.vue index 7aac3a0..9ac0596 100644 --- a/components-diy/diy-recommend-code.vue +++ b/components-diy/diy-recommend-code.vue @@ -1322,7 +1322,12 @@ onShareClick() { ctx.setFontSize(36); ctx.setFillStyle(v.codeColor || '#DC143C'); ctx.setTextAlign('center'); - ctx.setFontWeight('bold'); + // setFontWeight 是新版 canvas 2d API,旧版不支持;用 font 字符串兜底 + if (typeof ctx.setFontWeight === 'function') { + ctx.setFontWeight('bold'); + } else { + try { ctx.font = 'bold 36px sans-serif'; } catch(e) {} + } ctx.fillText(code, W / 2, blockY + blockH / 2 + 12); // 6. 二维码(如果有 url) const qr = this.qrcodeRenderUrl;