记录html2canvas页面截图

因为我的项目须要页面截图性能,我就找到了html2canvas插件

<div ref="shareDom">
<div class="exclude"><div>
<div>
<button @click="goShare()">分享<button>

 js

async goShare(){
let dom = this.$refs["shareDom"];
const res = await html2canvas(dom, {
width: parseInt(window.getComputedStyle(dom).width),
height: parseInt(window.getComputedStyle(dom).height),
allowTaint: true,
taintTest: false,
scale: window.devicePixelRatio, 设施像素比
ignoreElements:(element)=>{ 可从渲染中删除匹配的元素
if(element.className === 'exclude') return true;
},
})
this.imgUrl = res.toDataURL()
}

最初就是一张base64图片。

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理