需求是想把canvas转成img替换掉,为什么会报错呢
<el-col v-for="(item,index) in 10">
<div class="canvas-item">
<qrcode-vue value="123" :size="150" /> // 这边是个canvas
</div>
</div>
const canvasToImg = () => {
const canvasItems = document.querySelectorAll(".canvas-item")
canvasItems.forEach((item) => {
const { canvas } = item
if (canvas) {
const image = new Image()
image.src = canvas.toDataURL("image/png")
item.html(image)
}
})
}
它返回的是一个列表你要遍历一下