Html2canvas screenshot Blank question

Source: Internet
Author: User

Recently encountered a requirement in the project, need to provide the function of the webpage. Baidu found Html2canvas very useful. Then try it.

Resources

Plugin: Html2canvas

How to use

The React component development method used by the project. Refer to the official documentation getting-started.md and follow these steps:
1. Install with the following command
NPM Install Html2canvas--save
2. Introduction of Html2canvas in documents
Import Html2canvas from ' Html2canvas ';
3, the use of the file
Html2canvas (document.body). Then (function (canvas) {
Document.body.appendChild (canvas);
});

Problems encountered

In this way, the page does not have scroll bar is OK, there are scroll bars when there is a large space.
The error is as follows:

Solution Solutions

Take a closer look at the analysis of Configuration.md and netizens, and finally solve. The code snippet is as follows

The previous one is correct as follows:

Description of the configuration item in the code

1, the blank is due to the problem of container height setting, the height of setting windowheight is equal to the height of the page contains scroll bar to get the content in the scroll bar. This article can solve the problem of blank.
2, set the width, Height property is because we display in the page width and height is fixed, is the current screen visible area.
3, set the x, Y coordinate because the page in the scroll bar, you need to specify the starting position. There is no scrollbar in the x-axis direction in this project, so it is set to zero and the Y-direction has scroll bars, so you need to get the scrolling coordinates of the current direction.
4, the General page will have the picture, the picture has the link address, the setting Allowtaint property can guarantee the picture loading.

Html2canvas Blank question

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.