handleCanvas() {
this.$Loading(true)
let ctx = uni.createCanvasContext('payImg', this)
ctx.drawImage('图片地址', 0, 0, 545, 674)
ctx.save(); //保存
ctx.draw(false, () => {
setTimeout(() => {
$this.handleTempFilePath()
}, 1500)
})
this.$Loading(false)
$this.showImg = true
},
//获取绘制的图片
handleTempFilePath() {
console.log(1);
uni.canvasToTempFilePath({
x: 0,
y: 0,
width: 545,
height: 674,
destWidth: 545,
destHeight: 674,
fileType: 'jpg',
quality: 1,
canvasId: 'payImg',
success: function(res) {
// 在H5平台下,tempFilePath 为 base64
$this.imgUrl = res.tempFilePath
console.log(res)
},
fail(res) {
console.log(res);
},
complete(res) {
console.log(res);
},
})
},
1 个回复
嗨哆嚒 (作者) - 嗨哆嚒
csdn找到的解决方案,两个方法可以执行了,但执行结果为空白
ctx.draw(false, (() => {
setTimeout(() => {
console.log('画好了');
//其他处理
}, 1500)
})())