admin管理员组文章数量:1323524
I have updated html2canvas from 0.4 to 1.0.0 and I used the function below to take a screenshot.
The function and html2canvas does not work and I got the error below.
How do I solve it?
icefaces-pat.js.jsf?ln=icepat&v=3_3_0_130416:1 2ms html2canvas: onrendered option is deprecated, html2canvas returns a Promise with the canvas as the value
function screenshotChrome() {
var target = $(document.body);
html2canvas(target, {
useCORS: true,
onrendered: function (canvas) {
canvas.UniversalToBlob(function (blob) {
saveAs(blob, "aScreenshot.png");
},
"image/png", 1);
}
});
}
I have updated html2canvas from 0.4 to 1.0.0 and I used the function below to take a screenshot.
The function and html2canvas does not work and I got the error below.
How do I solve it?
icefaces-pat.js.jsf?ln=ice.pat&v=3_3_0_130416:1 2ms html2canvas: onrendered option is deprecated, html2canvas returns a Promise with the canvas as the value
function screenshotChrome() {
var target = $(document.body);
html2canvas(target, {
useCORS: true,
onrendered: function (canvas) {
canvas.UniversalToBlob(function (blob) {
saveAs(blob, "aScreenshot.png");
},
"image/png", 1);
}
});
}
Share
Improve this question
asked Apr 26, 2018 at 13:55
YamurYamur
3396 silver badges20 bronze badges
2
-
As the warning suggests...
html2canvas()
now returns a promise. For examplehtml2canvas(...).then(canvas => ...)
– Adriano Repetti Commented Apr 26, 2018 at 13:58 - guessing people do not search error messages anymore github./MrRio/jsPDF/issues/1610 – epascarello Commented Apr 26, 2018 at 13:58
1 Answer
Reset to default 7I'm not familiar with the library, but the error says that this version uses a Promise
instead of using the onrendered
callback option. Therefore, it is (probably) used like:
html2canvas(target, {
useCORS: true
})
.then(function (canvas) {
canvas.UniversalToBlob(function (blob) {
saveAs(blob, "aScreenshot.png");
}, "image/png", 1);
})
.catch(function (err) { console.log(err); });
本文标签: javascriptLatest version of HTML2CANVAS does not work in ChromeFirefoxStack Overflow
版权声明:本文标题:javascript - Latest version of HTML2CANVAS does not work in Chrome, Firefox - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742133599a2422272.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论