canvas 2d 预览 不支持drawImage 另外一个实例的画布呢
发布于 4 年前 作者 yancao 9151 次浏览 来自 问答

开发工具可以

手机上预览这个方法不行: ctx1.drawImage(ctx.canvas,0,0)

 const queryTwo = wx.createSelectorQuery()
      queryTwo.select('#myCanvasTwo')
        .fields({ nodetruesizetrue })
        .exec((res) => {
            console.log(res)
          const canvas = res[0].node
          var ctx = canvas.getContext('2d')
          

          const query = wx.createSelectorQuery()
          query.select('#myCanvas3')
            .fields({ nodetruesizetrue })
            .exec((res) => {
                console.log(res)
              const canvas1 = res[0].node
              const ctx1 = canvas1.getContext('2d')
              console.log(ctx1)
              const dpr2 = wx.getSystemInfoSync().pixelRatio
              canvas1.width = res[0].width * dpr2
              canvas1.height = res[0].height * dpr2
              console.log(dpr2)
              console.log(ctx1)
              console.log(canvas1.width)
              console.log(canvas1.height)
              console.log(ctx)
              // ctx1.scale(dpr, dpr)
           
              ctx1.drawImage(ctx.canvas,0,0)
              
            })
        })

1 回复

提供这种格式的代码片段,描述下复现流程(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部