canvas2d 新接口怎么绘制图片无效呢?
如图可以正确的绘制出矩形,但是图片始终出不来,纯小白一个,希望路过的大大指点一下
onReady: function () {
const query = wx.createSelectorQuery()
query.select('#mycanvas')
.fields({ node: true, size: true })
.exec((res) => {
const canvas = res[0].node
const ctx = canvas.getContext('2d')
const dpr = wx.getSystemInfoSync().pixelRatio
canvas.width = res[0].width * dpr
canvas.height = res[0].height * dpr
ctx.scale(dpr, dpr)
const img = canvas.createImage()
img.src = "../../assets/stickers/stickers1.jpg"
ctx.drawImage(img, 0, 0, 100, 100)
ctx.fillRect(0, 0, 100, 100)
})
},