因为你没有执行 `draw()`,实际画布不会有任何内容的。
canvas 2d 画图成功后,导出图片是空白?canvas 2d已经画图完成了,[图片]导出图片后,点击本地链接[图片]图片是空白的[图片] 这个代码 /**画布分享链接的海报1 */ canvasImg1: function (template, img, callback) { let that = this; let rpx = that.globalData.rpx; const query = wx.createSelectorQuery() query.select(template) .fields({ node: true, size: true }) .exec((res) => { const canvas = res[0].node const ctx = canvas.getContext('2d') canvas.width = 442 * rpx canvas.height = 365 * rpx const codeImg = canvas.createImage(); codeImg.src = img; codeImg.onload = () => { ctx.drawImage(codeImg, 0, 0, 442 * rpx, 264 * rpx, ); ctx.save(); } const codeImg2 = canvas.createImage(); codeImg2.src = '/images/icon/btn.png'; codeImg2.onload = () => { ctx.drawImage(codeImg2, 14 * rpx, (264 + 8) * rpx, 396 * rpx, 56 * rpx, ); ctx.save(); } setTimeout(function () { wx.canvasToTempFilePath({ canvas, success(res) { callback(res.tempFilePath) } }) }, 300); }) },
2020-06-19