This commit is contained in:
aihe 2024-05-13 19:02:16 +08:00
parent 8441d5eb09
commit 5d3ac55f07

View File

@ -6,7 +6,7 @@
<template v-slot:content>
<view class="pt-20 pb-10">打印内容</view>
<view class="canvas-con">
<canvas canvas-id="shareCanvas" :style="{width:canvasWidth + 'px', height: canvasHeight + 'px'}"></canvas>
<canvas :canvas-id="canvasId" :style="{width:canvasWidth + 'px', height: canvasHeight + 'px'}"></canvas>
</view>
</template>
</tpx-bluetooth>
@ -36,7 +36,7 @@ export default {
},
data () {
return {
canvasId: 'shareCanvas',
canvasId: uni.$u.guid(20),
canvasWidth: 1,
canvasHeight: 1,
imgData: '',
@ -110,6 +110,9 @@ export default {
console.log("===renderCanvasImg:filePath=====", filePath)
return new Promise(async (resolve, reject)=> {
try{
// 多次渲染,createCanvasContext,必须使用新的才可以
that.canvasId = uni.$u.guid(20)
await promiseTimeout(500)
let res = await getImageInfo(filePath)
console.log("getImageInfo res====", res)
const ctx = uni.createCanvasContext(that.canvasId, that);