0

在图层上有带有图像和线条的 v-group,舞台如下:

<button @click="export"></button>
<v-layer ref="layer">
<v-group>
<v-image :config="configBackground"></v-image>
<v-line
v-for="line in lines"
:key="line.id"
:config="{
stroke: 'red',
points: line.points,
}"
/>
</v-group>
</v-layer>

在我的函数中,我尝试从舞台获取 dataurl 以保存 img:

export(e) {
//console.log(e.target.getStage())
let dataURL = e.target.toDataURL()
console.log(dataURL)
// this.download(dataURL, "img.png")
},

如果我单击按钮,我会得到e.target.toDataURL 不是函数

如何获取 dataURL 来保存图像?

4

1 回答 1

0

这对我有用

let stage = vm.$refs.stage.getNode()
let dataURL = stage.toDataURL()
于 2022-02-03T16:08:51.310 回答