html52.com
我爱小程序-开发者交流社区

canvas2d,真机调试时报错?(U.createEvent is not a function)

报错完整信息:

MiniProgramError U.createEvent is not a function TypeError: U.createEvent is not a function

经过测试,使用如下代码的exec时会报错,去掉exec后就不报错了。

// js
 wx.createSelectorQuery()
      .select('#canvas')
      .fields({
        node: true,
        size: true,
      })
      .exec(this.init.bind(this))
// wxml
<canvas
  type="2d"
  id="canvas"
  style="width: 300px; height: 300px;"
></canvas>

网友回复

社区技术运营专员-Jahozheng:

暂不支持真机调试 可以试试真机预览

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付