微信小程序canvas绘制图片真机不显示问题

用canvas绘制图片的时候,模拟器上正常显示,真机上不显示

const ctx = wx.createCanvasContext('canvasImg');
var imgUrl = 'https://static.bzsh.souqu.net/20191119095703c82818277.png';
ctx.drawImage(imgUrl, 40, 100, 200, 200);
ctx.draw();

用 wx.getImageInfo 将网络图片转成本地路径,在真机就能正常显示了

const ctx = wx.createCanvasContext('canvasImg') 
var imgUrl = 'https://static.bzsh.souqu.net/20191119095703c82818277.png';
//将网络图片转成本地路径     
wx.getImageInfo({             
	src: imgUrl,     
	success: function(res) {
		ctx.drawImage(res.path, 40, 100, 200, 200)               
		ctx.draw();   
	}
})

你可能感兴趣的:(微信小程序)