https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createOffscreenCanvas.html
let src = '/medias/img/printer_logo.jpg';
let _this = this;
wx.getImageInfo({
src: src,
success(res) {
console.info(res, wx.createOffscreenCanvas);
let canvas = wx.createOffscreenCanvas({
type: '2d',
width: res.width,
height: res.height
});
let cont = canvas.getContext('2d');
cont.clearRect(0, 0, res.width, res.height);
let img = canvas.createImage();
img.onload = function () {
cont.drawImage(img, 0, 0, res.width, res.height, 0, 0, res.width, res.height);
logoImageData = cont.getImageData(0, 0, res.width, res.height);
}
img.src = src;
}
});
只测试真机调试有这个问题,错误位置就是 wx.createOffscreenCanvas() 调用报错了,具体不知道是哪里有问题,代码是放在组件内
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
自定义组件要添加compInst