canvas组件在pc上不支持吗?
发布于 4 年前 作者 panjuan 3193 次浏览 来自 官方Issues
Page({
  onReady() {
    const query = wx.createSelectorQuery()
    query.select('#canvas')
      .fields({ nodetruesizetrue })
      .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(00100100)
      })
  }
})
直接用了文档上的代码,在pc小程序上没有效果。res[0].node 为null

pc不支持canvas吗?
3 回复

应该说是canvas2d,pc上无法获取node

目前暂不支持pc端

不知道为什么,重来没在PC上成功打开过小程序

回到顶部