wx.canvasGetImageData 无法获取象素

发布于 8 年前作者 fangjuan15441 次浏览最后编辑 8 年前来自 issues

https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasGetImageData.html

wx.canvasGetImageData({
  canvasId: 'canvasBox',
  x: 0,
  y: 0,
  width: 100,
  height: 100,
  success(res) {
    console.log(res.width) // 100
    console.log(res.height) // 100
    console.log(res.data instanceof Uint8ClampedArray) // true
    console.log(res.data.length) // 100 * 100 * 4
  },
   complete(res) { console.log( res ) }
})

{errMsgcanvasGetImageData: fail canvas is empty} api不生效

3 回复
tao14
tao141 楼6 年前

麻烦提供能复现问题的代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

uhe
uhe2 楼6 年前

错误提示很明显,没有获取到canvas

jiajie
jiajie3 楼6 年前

可否提供下代码片段