问题
is there anyway to solve this issue? The html2canvas is not rendering when the document.body height is more than 30,000 pixels. Or can i render the current viewport only? On what the user can see?
Please help.
回答1:
To be able to render only current active viewport you can initialize html2canvas with type:'view'
option
example:
var body = document.getElementsByTagName("body")[0];
html2canvas(body, {
type: 'view',
onrendered: function(canvas) {
//implementation
}
})
I tested the above code with html2canvas
version 0.5.0-beta4
and it capture only the current viewport correctly, even if you scroll to the bottom of the page
Regarding 30,000 pixels, you can check the answer mentioned by @kaiido
来源:https://stackoverflow.com/questions/46881957/html2canvas-not-rendering-the-document-body-when-its-more-than-30-000-pixels-lon