let canvas = wx.createOffscreenCanvas({ type: '2d', width: 1200, height: 342, compInst: this })
const context = canvas.getContext('2d')
const width = 1200
const height = 342
const image = canvas.createImage()
await new Promise(resolve => {
image.onload = resolve
image.src = '...'
})
return new Promise((resole, reject) => {
context.clearRect(0, 0, width, height)
context.drawImage(image, 0, 0, width, height)
context.fillStyle = '#fff'
context.font = "36px serif";
context.fillText('测试', 42, 48)
wx.canvasToTempFilePath({
width: width,
height: height,
canvas: canvas,
canvasId: canvas.id,
success(res) {
resole(res.tempFilePath)
},
fail: (err) => {
reject(err)
}
机型:ios16.5 iPhone 13 mini
基础库:3.0.2
代码片段:https:
改好了 你去看看吧
https://developers.weixin.qq.com/s/IJRFrjmd7ILA
canvas.id是啥?