Commit e3ee6814 authored by 毛线's avatar 毛线

获取图片方法修改

parent 25eec5c9
......@@ -157,7 +157,7 @@ export default {
this.$refs.canvas?.draw()
},
// 导出图片
getImage() {
downImage() {
// this.$Screenshot(document.querySelector('#wrapper')).then(canvas => {
// this.downFile(canvas.toDataURL('image/jpeg', 0.8), new Date().getTime())
// this.$message.success('图片导出成功')
......@@ -180,6 +180,18 @@ export default {
URL.revokeObjectURL(elink.href) // 释放URL对象
})
},
getImage() {
return new Promise((resolve, reject) => {
html2canvas(this.$refs.main, {
useCORS: true, // 【重要】开启跨域配置
scale: window.devicePixelRatio < 3 ? window.devicePixelRatio : 2,
allowTaint: true, // 允许跨域图片
}).then((canvas) => {
const imgData = canvas.toDataURL('image/jpeg', 1.0)
resolve(imgData)
})
})
},
// 定位到某个图层
selectIndex(index) {
this.activeIndex = (Number)(index)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment