Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zibuyu1 opened this issue Apr 10, 2020 · 4 comments
Open

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

zibuyu1 opened this issue Apr 10, 2020 · 4 comments

Comments

@zibuyu1
Copy link

zibuyu1 commented Apr 10, 2020

你好,我把这个改造成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 zibuyu1 changed the title Cannot read property 'xiaoying' of null 改造成uni-app版本的小程序使用 Apr 10, 2020
@Sssnone
Copy link

Sssnone commented May 28, 2020

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

@zibuyu1
Copy link
Author

zibuyu1 commented May 28, 2020

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

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

@Sssnone
Copy link

Sssnone commented May 29, 2020

感谢老哥。🙏🙏🙏

@Gitjinfeiyang
Copy link

推荐这个canvas库 easy-canvas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants