mp_canvas_drawer icon indicating copy to clipboard operation
mp_canvas_drawer copied to clipboard

改造成uni-app版本的小程序使用

Open zibuyu1 opened this issue 4 years ago • 4 comments

你好,我把这个改造成uni-app版本的,绘图成功了,但是会报Cannot read property 'xiaoying' of null,

saveImageToLocal () { const width = this.width; const height = this.height; wx.canvasToTempFilePath({ x: 0, y: 0, width, height, canvasId: 'canvasdrawer', complete: res => { if (res.errMsg === 'canvasToTempFilePath:ok') {

        // 有这三行代码会报错:Cannot read property 'xiaoying' of null
        this.showCanvas = false;
        this.isPainting = false;
        this.tempFileList = [];
        // 有这三行代码会报错:Cannot read property 'xiaoying' of null

        this.$emit('getImage', {tempFilePath: res.tempFilePath, errMsg: 'canvasdrawer:ok'})
      } else {
        this.$emit('getImage', {errMsg: 'canvasdrawer:fail'})
      }
    }
  }, this)
}

zibuyu1 avatar Apr 10 '20 11:04 zibuyu1

老哥。咋解决的啊。我马上也要在uni-app里用这个。

Sssnone avatar May 28 '20 09:05 Sssnone

老哥。咋解决的啊。我马上也要在uni-app里用这个。

除了配置白名单,和图片地址必须是https格式外,我稍微改造了下代码, 搬砖,照着大佬代码改做了一个uni-app版本的 https://github.com/zibuyu1/uni-app-weixin

zibuyu1 avatar May 28 '20 10:05 zibuyu1

感谢老哥。🙏🙏🙏

Sssnone avatar May 29 '20 02:05 Sssnone

推荐这个canvas库 easy-canvas

Gitjinfeiyang avatar Aug 28 '20 16:08 Gitjinfeiyang