1 组件中引用canvas【一点要加this】
let ctx = wx.createCanvasContext('posterCanvas',this); //需要加this
2 如在组件外调用组件内的canvas需要绑定上下文
drawImg(tempFilePaths, canvasWidth, canvasHeight){
let that = this
let cavsid = this.cavid
let ctx = wx.createCanvasContext(cavsid, that);
ctx.drawImage(tempFilePaths, 0, 0, canvasWidth, canvasHeight)
ctx.draw()
wx.canvasToTempFilePath({
canvasId: cavsid,
success: function (res) {
....
}
}, that)//就是这个that
}