canvas 2d wx.createSelectorQuery()返回值取不到nod的问题?
发布于 6 年前 作者 na27 7998 次浏览 来自 问答
wx.createSelectorQuery().in(that)
          .select('#myCanvas')
          .fields({
            node: true,
            size: true,
          }).exec(that.drawImage);
drawImage: function (res) {
    console.log(res);
    console.log(new Date().getTime());
    console.log('绘制1');
    wx.hideLoading();
    /*wx.showLoading({
      title: '图片绘制中...',
    });*/
    //绘制canvas图片
    var that = this;
    var width = res[0].width; console.log(width);
    var height = res[0].height; console.log(height);

    var heightbl = height / 490;
    var widthbl = width / 335;

    that.setData({ heightbl: heightbl, widthbl: widthbl, canvasHeight: height, canvasWidth: width });

    var canvas = res[0].node; console.log(res[0].node);

}

 <canvas type="2d" canvas-id="myCanvas" id="myCanvas" style="width:670rpx;height:980rpx;"></canvas>

前一个是android 后一个是 ios  console.log(res);输出的结果不一样  android 找不到node对象   这怎么解决?
1 回复

你好,麻烦具体描述问题流程,提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部