简体   繁体   中英

How to get started with html2canvas

Okay, so this might seem like a simple question... But I'm new to part of stuff. On http://html2canvas.hertzen.com/getting-started it shows a very small tutorial... When I run npm install -g html2canvas , it works great. Now comes the part where I'm actually lost. Where do I put the code import html2canvas from 'html2canvas'; ? Do I just put this at the top of the javascript file?

import statement is an feature, they are intended to be used at the very top of any Javascript file.

MDN Definition

The import statement is used to import bindings which are exported by another module. Imported modules are in strict mode whether you declare them as such or not. The import statement cannot be used in embedded scripts.

so, in your case simply use import html2canvas from 'html2canvas'; at the top of your file.

However, if you're not using or some kind of transpiler ( for example), then it won't work , because it's currently not supported in every navigator.

If you're not using a transpiler or google-chrome, think about using

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM