This commit is contained in:
parent
464f39dac8
commit
c78233a2f4
|
@ -106,6 +106,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Search } from '@element-plus/icons-vue'
|
import { Search } from '@element-plus/icons-vue'
|
||||||
import html2canvas from 'html2canvas';
|
import html2canvas from 'html2canvas';
|
||||||
|
import { toPng } from 'html-to-image';
|
||||||
import { onMounted, ref,watch, reactive, getCurrentInstance,nextTick } from 'vue'
|
import { onMounted, ref,watch, reactive, getCurrentInstance,nextTick } from 'vue'
|
||||||
|
|
||||||
import {listEntpcoursework, listEntpcourseworkNew, getEntpcoursework} from '@/api/education/entpCourseWork'
|
import {listEntpcoursework, listEntpcourseworkNew, getEntpcoursework} from '@/api/education/entpCourseWork'
|
||||||
|
@ -438,12 +439,25 @@ const getPaginationList = ( page, limit ) => {
|
||||||
*/
|
*/
|
||||||
const captureScreenshot = (id) => {
|
const captureScreenshot = (id) => {
|
||||||
const targetElement = document.getElementById('screenshot-target-' + id);
|
const targetElement = document.getElementById('screenshot-target-' + id);
|
||||||
html2canvas(targetElement).then(canvas => {
|
// html2canvas(targetElement).then(canvas => {
|
||||||
// 将canvas转换为图像URL
|
// console.log(canvas);
|
||||||
const screenshotUrl = canvas.toDataURL('image/png');
|
// // 将canvas转换为图像URL
|
||||||
// 在这里可以将截图保存到本地或上传到服务器
|
// const screenshotUrl = canvas.toDataURL('image/png');
|
||||||
// console.log(screenshotUrl);
|
// // 在这里可以将截图保存到本地或上传到服务器
|
||||||
emit('addQuizImgBs64', screenshotUrl);
|
// // console.log(screenshotUrl);
|
||||||
|
// emit('addQuizImgBs64', screenshotUrl);
|
||||||
|
// });
|
||||||
|
// const node = document.querySelector('#img')
|
||||||
|
console.log(targetElement)
|
||||||
|
toPng(targetElement).then((dataUrl) => {
|
||||||
|
// 使用图片数据URL
|
||||||
|
console.log(dataUrl);
|
||||||
|
// this.imgUrl = dataUrl
|
||||||
|
// console.log(this.imgUrl)
|
||||||
|
emit('addQuizImgBs64', dataUrl);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.error('转换错误:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue