ShirlyChenLaLaLa / ShirlyChenLaLaLa.github.io

学习前端的一些记录
Other
1 stars 0 forks source link

 用draw回调来解决保存空白就可以了,用的await没出现这个问题了 #1

Open bulolo opened 6 years ago

bulolo commented 6 years ago
_this.ctx.draw(false, async() => {
          let res = await wepy.canvasToTempFilePath({
            x: 0,
            y: 0,
            quality: 1,
            width: _this.cvsSize.width,
            height: _this.cvsSize.height,
            destWidth: _this.cvsSize.width * 10,
            destHeight: _this.cvsSize.height * 10,
            canvasId: 'avatarCanvas'
          })
        try {
          await wepy.saveImageToPhotosAlbum({
            filePath: res.tempFilePath
          })
        } catch (error) {

        }
          this.$apply()
        })

出现第一次空白,只是开发者工具问题,到了真机,其实是不会出现空白。

ShirlyChenLaLaLa commented 6 years ago

谢谢