html2canvas.js截图只截取当前可视区域,滚动条以下获取不到。
自行百度了一顿,找到了一种方法,以为成功了。
var height = $("#pdfCont").height()
//克隆节点,默认为false,不复制方法属性,为true是全部复制。
var cloneDom = $("#pdfCont").clone(true);
//设置克隆节点的css属性,因为之前的层级为0,我们只需要比被克隆的节点层级低即可。
cloneDom.css({
"background-color": "white",
"position": "absolute",
"top": "0px",
"z-index": "-1",
"height": height
});
//将克隆节点动态追加到body后面。
$("body").append(cloneDom);
html2canvas(cloneDom,{
//Whether to allow cross-origin images to taint the canvas
allowTaint: true,
//Whether to test each image if it taints the canvas before drawing them
taintTest: false,
onrendered:function(canvas) {
document.body.appendChild(canvas);
}
然发现节点copy不了echarts的图表,导致截图的时候没有echart的图表。 到底应该怎么处理啊。
楼主 你用html2canvas截echarts的图表时,echarts图表会很模糊吗?我现在大屏幕上下载有echarts图表的区域截图时,echart图表会很模糊,小屏幕下载就还好