fail canvas is empty
代码:
var res = wx.getSystemInfoSync();
const ctx = wx.createCanvasContext(‘myCanvas’);
ctx.drawImage(’…/…/resource/img/dlt.jpeg’, 0, 0, res.windowWidth, res.windowHeight);
ctx.draw();
wx.canvasToTempFilePath({
x: 100,
y: 200,
width: 50,
height: 50,
destWidth: 100,
destHeight: 100,
canvasId: ‘myCanvas’,
success: function (res) {
console.log(res.tempFilePath)
},
fail: function (e) {
console.log(e);
}
})
图片可以画出来,但是保存的时候输出:fail canvas is empty,这是什么原因?