收藏
回答

canvas无法渲染(ctx.drawImage)云存储的图片?

Page({
  onLoad: function (options) {
    wx.createSelectorQuery()
      .select('#ccc')
      .fields({
        node: true,
        size: true,
      })
      .exec(this.init.bind(this))
  },
  init(res) {
    const canvas = res[0].node
    const ctx = canvas.getContext('2d')
    const img = canvas.createImage()
    img.onload = () => {
      this._img = img
    }
    wx.cloud.downloadFile({
      fileID: 'cloud://cloud-aaaaaaaaaa.xxxxxxxxxxxxxxxxxx.jpg'
    }).then(res => {
      const path = res.tempFilePath
      console.log('rrrrr', res)
      img.src = path //这里报错了
    })
  },


  render(ctx) {
    // ctx.drawImage(this._img,0,0)
  }
})


报错信息为'500 (Internal Server Error)',无法访问这个图片资源. 但是 'res' 里面是有东西的.

最后一次编辑于  2020-08-10
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签