WeChat Mini Programs custom component. The canvas picture has been drawn successfully, but it is not displayed on the page.

using canvas, images in custom components has been drawn, and printing is successful. Using the image tag on the page to render also did not render. Answer
clipboard.png

clipboard.png

problem description

the environmental background of the problems and what methods you have tried

related codes

const QR = require (".. /.. / libs/qrcode.js");
Component ({
/ *

)
  • component property list

* /
properties: {


cardNo:{
  type:Number,
  value:{}
},
startDt:{
  type: String,
  value: {}
},
endDt:{
  type: String,
  value: {}
},
cardCode: {
  type: Object,
  value: {},
  observer:function(val){
    if(val && this.data.cardNo){
      this.createQrCode(this.data.cardNo, "mycanvas", 150, 150)
    }
  }
}

},

methods: {

createQrCode(url, canvasId, cavW, cavH) {
  //draw
  QR.api.draw(url, canvasId, cavW, cavH);
  setTimeout(() => { this.canvasToTempImage(this); }, 1000);
},
//data
canvasToTempImage() {
  wx.canvasToTempFilePath({
    canvasId: "mycanvas",
    success: (res) => {
      console.log("",res)
      var tempFilePath = res.tempFilePath;
      this.setData({
        imagePath: tempFilePath,
      });
    },
    fail: function (res) {
      console.log("",res)
    }
  },this);
},

}
})

what result do you expect? What is the error message actually seen?

Sep.16,2021
Menu