html52.com
我爱小程序-开发者交流社区

canvas绘制本地图片 在开发者工具可以显示出来 真机无法显示?

this.gradeList.forEach((item, index) => {

if (this.changeIndex >= item.index) {

ctx.drawImage(okpng, 32, 260 + (index + 1) * 30, 18, 16);

ctx.setFontSize(15);

ctx.setFillStyle("#80442B");

ctx.textAlign = "left";

ctx.fillText(item.title, 61, 275 + (index + 1) * 30);

}

});



网友回复

微盟:

需要用 wx.getImageInfo 将图片转成临时路径,这样在真机上就能正常预览了

      wx.getImageInfo({
        src: okpng,//服务器返回的图片地址
        success: function (res) {
          //res.path是网络图片的本地地址
          let Path = res.path;
          ctx.drawImage(Path, 32260 + (index + 1) * 301816);
        },
        fail: function (res) {
          //失败回调
        }
      });



评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付