如题,编译成小程序,必须得在回调中使用,不然会导致生成图片空白
- 发布:2018-10-25 15:56
- 更新:2019-11-27 11:41
- 阅读:4482
大哥,怎么使用成功的,能上传一段代码吗
-
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
-
你好,我这里用了这个方法之后,昨天调试成功了,但是在今天调试失败,我测试了一下,发现这个方法成功之后,返回的base64有时候返回得不全,你又遇到这样的情况吗???
2019-02-26 11:45
这样的代码,在网页里可以执行,到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')
})