亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何讓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 關注
  • 3200 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號