收藏
回答

getImageInfo 后使用 drawImage 仍然报错?

wx.getImageInfo({
  src: imgUrl,
  success (tempImage) {
  query
  .select('#myCanvas')
  .fields({ node: true, size: true })
  .exec(res => {
    const canvas = res[0].node
    const ctx = canvas.getContext('2d')
    const dpr = wx.getSystemInfoSync().pixelRatio
    canvas.width = res[0].width * dpr
    canvas.height = res[0].height * dpr
    ctx.scale(dpr, dpr)
    // ctx.fillRect(0, 0, canvas.width, canvas.height)
    console.log('image-temp-path', tempImage.path)
    ctx.drawImage(tempImage.path, 0, 0, 300, 300)
   });
 },
 fail (err) {
   console.error('err from getImageInfo', err)
 }
})

回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签