This commit is contained in:
parent
464f39dac8
commit
c78233a2f4
|
@ -106,6 +106,7 @@
|
|||
<script setup>
|
||||
import { Search } from '@element-plus/icons-vue'
|
||||
import html2canvas from 'html2canvas';
|
||||
import { toPng } from 'html-to-image';
|
||||
import { onMounted, ref,watch, reactive, getCurrentInstance,nextTick } from 'vue'
|
||||
|
||||
import {listEntpcoursework, listEntpcourseworkNew, getEntpcoursework} from '@/api/education/entpCourseWork'
|
||||
|
@ -438,13 +439,26 @@ const getPaginationList = ( page, limit ) => {
|
|||
*/
|
||||
const captureScreenshot = (id) => {
|
||||
const targetElement = document.getElementById('screenshot-target-' + id);
|
||||
html2canvas(targetElement).then(canvas => {
|
||||
// 将canvas转换为图像URL
|
||||
const screenshotUrl = canvas.toDataURL('image/png');
|
||||
// 在这里可以将截图保存到本地或上传到服务器
|
||||
// console.log(screenshotUrl);
|
||||
emit('addQuizImgBs64', screenshotUrl);
|
||||
});
|
||||
// html2canvas(targetElement).then(canvas => {
|
||||
// console.log(canvas);
|
||||
// // 将canvas转换为图像URL
|
||||
// const screenshotUrl = canvas.toDataURL('image/png');
|
||||
// // 在这里可以将截图保存到本地或上传到服务器
|
||||
// // 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