比如说,我的内容区域为3000px的高度,但是html2canvas只能截取屏幕的可视区域。
哪个大佬知道怎么解决吗?
修改源码:自定义宽高
var width = options.width != null ? options.width : node.ownerDocument.defaultView.innerWidth;
var height = options.height != null ? options.height : node.ownerDocument.defaultView.innerHeight;
return renderDocument(node.ownerDocument, options, width, height, index).then(function (canvas) {**
if (typeof(options.onrendered) === "function") {
log("options.onrendered is deprecated, html2canvas returns a Promise containing the canvas");
options.onrendered(canvas);
}
return canvas;
});
调用:
var height = $('#htmlcanvas').outerHeight(true);
if(height <= 650 || height>=1024){height += 53;}//适配
html2canvas($("#htmlcanvas"),{
height:height,
// window.devicePixelRatio是设备像素比
// dpi: 192,//放大像素(2倍),以免图片模糊
dpi: window.devicePixelRatio,
}).then(function(....)}
13 回答13k 阅读
7 回答2.1k 阅读
3 回答1.3k 阅读✓ 已解决
6 回答1.2k 阅读✓ 已解决
2 回答1.4k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
6 回答1.1k 阅读
链接描述