收藏
回答

iphonex 使用createSelectorQuery 获取canvas节点 报错?

attached() {
  const dpr = wx.getSystemInfoSync().pixelRatio
  const query = wx.createSelectorQuery().in(this)
  this.dpr = dpr
  query.select('#canvas')
  .fields({node: true, size: true})
  .exec(res => {
  console.log(res,",,,,,,,,,,,,,,,,,,");
  const canvas = res[0].node
  const ctx = canvas.getContext('2d')
  canvas.width = res[0].width * dpr
  canvas.height = res[0].height * dpr
  ctx.scale(dpr, dpr)
  this.ctx = ctx
  this.canvas = canvas
})
}


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

2 个回答

登录 后发表内容
问题标签