使用canvas画布
context.draw(function(e){
console.log(e);
});
方法不走回调函数(开发工具和ios不走。安卓走)。怎么破。
而且手机端画布上啥也没有。编辑器上都有。
//将canvas转换为图片保存到本地,然后将图片路径传给image图片的src
createNewImg() {
var that = this
var unit = this.data.screenWidth / 375
var context = wx.createCanvasContext(‘mycanvas’)
var path = that.data.qtPaths
context.drawImage(path, 0, 0, 343 * unit, 220 * unit)
that.setMoney(context)
that.setName(context)
that.setQrcode(context)
//绘制图片
context.draw()
context.save()
//将生成好的图片保存到本地,需要延迟一会,绘制期间耗时
setTimeout(() => {
wx.canvasToTempFilePath({
canvasId: ‘mycanvas’,
success: function(res) {
wx.hideLoading()
that.setData({
imagePath: res.tempFilePath
})
},
fail: function(res) {
console.log(res.errMsg)
}
})
}, 2000)
},