微信小程序 canvas 2D 小米华为显示正常,iPhone6 iPhone8 生成后显示空白?
发布于 4 年前 作者 qiang56 621 次浏览 来自 官方Issues

另外开发者工具可以正常显示

    var promise1 = new Promise(function (resolve, reject{
      const photo = canvas.createImage()
      photo.onload = (e) => {
        resolve(photo);
      }
      photo.src = mainDatas.zang_bao
    });
    Promise.all(
      [promise1]
    ).then(res => {
      // 绘制白色背景
      ctx.fillStyle = "#ffffff";
      ctx.fillRect(00, posterDatas.width, posterDatas.height);
      //绘制[商品图片]
      ctx.drawImage(res[0], 00, posterDatas.width, 226)
      // ctx.drawImage(res[1], 17, 232, 35, 35)
      // ctx.drawImage(res[2], 240, 277, 60, 60)
      //绘制[姓名]
      ctx.font = "normal bold 10px Arial";
      ctx.fillStyle = "#000000";
      ctx.fillText(mainDatas.duihuan_name, 6590);
      //绘制[主题名称]
      ctx.font = "normal bold 10px Arial";
      ctx.fillStyle = "#000000";
      ctx.fillText(mainDatas.xiang_title, 117108);
      //绘制[奖章名称]
      ctx.font = "normal bold 15px Arial";
      ctx.fillStyle = "#D7363B";
      ctx.fillText(mainDatas.name_jiang, 117135);
        // 关闭loading
      wx.hideLoading();
      //显示海报
      posterDatas.show = true;
      posterDatas.success = true;
      that.setData({
        posterDatas
      })
    }).catch(err => {
      wx.hideLoading();
      wx.showToast({
        icon'none',
        title'海报生成失败,请稍后再试.',
      })
    })


回到顶部