Do Mini Program to share moments, developer tool canvas pictures work well, but what is the reason why canvas pictures are empty when debugging with mobile phones?

debugging canvas on the mobile phone to save the picture to the photo album is blank, there is no content on the canvas, hope the gods stop to help.

Mar.22,2021

the address of your image needs to start with https, and the domain name needs to be filled in the whitelist, and the developer tool needs to refresh the whitelist of the domain name.

take a look at my solution in this question: https://codeshelper.com/q/10.

.

I also encountered the same problem here found the answer:

  onLoad: function(options) {
    // ()
    let avatar_small_url = wx.getStorageSync('userInfo').avatar_small_url;
    // console.log(avatar_small_url)
    wx.getImageInfo({
      src: avatar_small_url,
      success:  (res)=> {
        //  console.log(res.path)
        this.setData({
          avatar_small_url: res.path
        })

      }
    })
  },

then use canvas to draw and save it, and then you can display

.
Menu