不会飞的羊
不会飞的羊
  • 发布:2018-10-25 15:56
  • 更新:2019-11-27 11:41
  • 阅读:4483

【报Bug】uni.canvasToTempFilePath(OBJECT, this) 需要在ctx.draw()回调中使用

分类:uni-app

如题,编译成小程序,必须得在回调中使用,不然会导致生成图片空白

2018-10-25 15:56 负责人:无 分享
已邀请:
1***@163.com

1***@163.com - 90后 IT男

回调这么用啊???

是在下输了

是在下输了

大哥,怎么使用成功的,能上传一段代码吗

  • 诗小柒

    ctx.draw(false, () => {

    // 保存到临时区域

    uni.canvasToTempFilePath({

    width: options.width,

    height: options.height,

    destWidth: options.width,

    destHeight: options.height,

    canvasId: options.canvasId,

    quality: Number(1),

    success: function (res) {


                    },  
    fail: function (res) {

    },
    complete: function () {
    },
    })
    })

    2019-02-25 11:10

  • 是在下输了

    你好,这个方法兼容uni-app H5版吗?

    2019-02-25 11:44

  • 诗小柒

    回复 是在下输了:兼容

    2019-02-25 11:50

  • 是在下输了

    你好,我这里用了这个方法之后,昨天调试成功了,但是在今天调试失败,我测试了一下,发现这个方法成功之后,返回的base64有时候返回得不全,你又遇到这样的情况吗???

    2019-02-26 11:45

  • 7***@qq.com

    回复 诗小柒: 谢谢分享!按照你的方法解决了,不过我是ctx.draw(true, () => {

    })才行

    2019-08-31 14:30

2***@qq.com

2***@qq.com

这样的代码,在网页里可以执行,到app里,连日志('ctx.draw@@@@--33333')都打印不出来了。请问你们解决了这个问题了吗?
ctx.draw(false,function(){
console.log('ctx.draw@@@@--33333')

                        setTimeout(function(){  
                            uni.canvasToTempFilePath({  
                                x: 0,  
                                y: 0,  
                                width: _this.canvasW,  
                                height: _this.canvasH,  
                                destWidth: _this.canvasW,  
                                destHeight: _this.canvasH,  
                                canvasId: 'myCanvas',  
                                success: (res) => {  
                                    console.log('生成海报成功,res.tempFilePath')  
                                    console.log(res.tempFilePath)  
                                    _this.base64=res.tempFilePath  
                                    _this.btnCanvasToShare()  
                                },  
                                fail:function () {  
                                    uni.showToast({title: '生成海报失败', icon: 'none'});  
                                }  
                            })  
                        },500)  
                        console.log('ctx.draw@@@@--222')  
                    })
  • 2***@qq.com

    没有解决,你的解决了吗?

    2019-12-02 07:35

该问题目前已经被锁定, 无法添加新回复