猿问

如何让html2canvas捕抓超出滚动条的部分。

设置了allowTaint : false没有效果,有网友提议先将要截图的部分拷贝到body下方进行隐藏然后再进行捕抓,想请教大神除此之外是否还有更简便的技巧呢?

跃然一笑
浏览 3168回答 1
1回答

慕桂英4014372

改下源码:主要是让用户调用时能够自定义需要截取Dom对象的宽和高return renderDocument(node.ownerDocument, options, node.ownerDocument.defaultView.innerWidth, node.ownerDocument.defaultView.innerHeight, 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;    });改成   //2016-02-18修改源码,解决BUG 对于部分不能截屏不能全屏添加自定义宽高的参数以支持    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;    });
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答