wx.downloadFile ({
url: 'http://qctm-assets.oss-cn-beijing.aliyuncs.com/newagent/reference_bg.png',
success(res){
imagesBg = res.tempFilePath
wx.setStorage({
key: 'imagesBg',
data: imagesBg,
});
const ctx = wx.createCanvasContext('myCanvas')
ctx.drawImage(imagesBg, 0, 0, 150, 100)
ctx.draw()
console.log('绘制成功');
},
})
使用downloadFile将网络图片转化为本地临时文件,绘制到canvas,图片不显示,也不报错
谢谢哈。刚刚找到问题了,canvas将type设置为2d了,导致将图片没有绘制出来