Canvas绘制图片无效
<canvas type=“2d” style=“width: 300; height: 200;” canvas-id=“firstCanvas”></canvas>
let ctx = wx.createCanvasContext(‘firstCanvas’)
wx.downloadFile({
url: ‘https://www.baidu.com/img/bd_logo1.png’,
success: res => {
console.log(res)
if (res.statusCode === 200) {
ctx.drawImage(res.tempFilePath, 10, 10, 150, 100)
ctx.draw()
}
}
})
2 回复