小程序使用canvas报错:"canvasToTempFilePath: fail canvas is empty"
为啥呢? 因为在自定义组件中使用canvas 需要添加this参数
wx.canvasToTempFilePath({
x: 0,
y: 0,
581 * util.pixelRatio,
height: 575 * util.pixelRatio,
canvasId: 'myCanvas',
fileType: 'jpg',
success: function (res) {
wx.hideLoading()
that.setData({
synthImgUrl: res.tempFilePath
})
},
fail: function (res) {
wx.hideLoading()
wx.showToast({
title: '生成失败',
icon: 'none'
})
}
},that)