隐藏指定元素:
方法一:data-html2canvas-ignore="true"
<div class="detail" data-html2canvas-ignore="true">
<el-button type="primary" size="small" @click="viewDetail(item)">查看详情</el-button>
</div>方法二:ignoreElements,麻烦,不建议用。
显示指定元素:
目前只找到一种方式:onclone。
#analyse-heade {
display: none;
}html2Canvas(dom, {
useCORS: true,
scale: 2,
allowTaint: true,
backgroundColor: '#fff',
onclone: cb => {
cb.getElementById('analyse-heade').style.display = 'block'
}
})
文章介绍了两种在使用html2canvas库时隐藏指定元素的方法:通过data-html2canvas-ignore属性和使用ignoreElements方法,同时提供了一种显示指定元素的方式,即在onclone回调中修改元素样式。这种方法主要用于网页内容的截图和渲染。

2万+

被折叠的 条评论
为什么被折叠?



