小程序使用canvas报错:"canvasToTempFilePath: fail canvas is empty"


小程序使用canvas报错:"canvasToTempFilePath: fail canvas is empty"

为啥呢? 因为在自定义组件中使用canvas 需要添加this参数

wx.canvasToTempFilePath({
            x: 0,
            y: 0,
            width: 581 * util.pixelRatio,
            height: 575 * util.pixelRatio,
            
            canvasId: 'myCanvas',
            fileType: 'jpg',
            success: function (res) {
              wx.hideLoading()
              that.setData({
                synthImgUrl: res.tempFilePath
              })
            },
            fail: function (res) {
              wx.hideLoading()
              wx.showToast({
                title: '生成失败',
                icon: 'none'
              })
            }
          },that)

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM