2 回答
TA贡献1795条经验 获得超7个赞
我最后发现了这个问题
HTML 的嵌套如下所示:
<div data-html2canvas-ignore="true">
<div>
<div id="export-main-0></div>
</div>
</div>
问题是其中一个父 div 上应用了 data-html2canvas-ignore 标签,这使得 html2canvas 无法检测到子 div。简单地从父 div 中删除 ignore 规则,一切都会再次工作。
TA贡献1111条经验 获得超0个赞
如果要克隆节点并添加元素或样式,
像这样尝试onclone:
html2canvas(elementById[index], {
onclone: function (documentClone) {
var headnode = document.createElement("h1");
var textnode = document.createTextNode('Hello World');
headnode.appendChild(textnode);
documentClone.querySelector('#list').prepend(headnode)
(<HTMLElement>documentClone.querySelector('body')).style.padding = '30px';
}
}).then(canvas => {
...
})
添加回答
举报