绘制海报,绘制完背景图片后怎么绘制二维码图片。还是说只能绘制一张图
draw(url, qrcode) {
wx.createSelectorQuery()
.select('#myCanvas') // 在 WXML 中填入的 id
.fields({ node: true, size: true })
.exec((res) => {
// Canvas 对象
const canvas = res[0].node
const ctx = canvas.getContext('2d')
const width = res[0].width
const height = res[0].height
canvas.width = width
canvas.height = height
const image = canvas.createImage()
image.src = url
image.onload = () => {
ctx.drawImage(image, 0, 0, 650, 885)
wx.canvasToTempFilePath({
canvas,
success: (res) => {
const list = [...this.data.imgBuffer, res.tempFilePath]
// 生成的图片临时文件路径
this.setData({
imgBuffer: list,
})
},
})
}
})
},
可以画多张