为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

跃然一笑 2018-11-21 10:15:31
设置了allowTaint : false没有效果,有网友提议先将要截图的部分拷贝到body下方进行隐藏然后再进行捕抓,想请教大神除此之外是否还有更简便的技巧呢?
查看完整描述

1 回答

?
慕桂英4014372

TA贡献1871条经验 获得超13个赞

改下源码:
主要是让用户调用时能够自定义需要截取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;

    });

查看完整回答
反对 回复 2018-12-17
  • 1 回答
  • 0 关注
  • 3166 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号