翻译自:html2canvas:getting-started

Learn how to start using html2canvas
学习如何开始使用html2canvas


安装 Installing

You can install html2canvas through npm or download a built release.
你可以通过NPM安装html2canvas或者下载一个release包

NPM安装

  1. npm install html2canvas

引入包

npm安装后,在js脚本中引入该包:

  1. import html2canvas from 'html2canvas';

使用 Usage

To render an element with html2canvas with some (optional) options, simply call html2canvas(element, options);
给html2canvas配置一些(可选的)参数来渲染元素,语法:html2canvas(element, options)

  1. html2canvas(document.body).then(function(canvas) {
  2. document.body.appendChild(canvas);
  3. });