Skip to content

Latest commit

 

History

History

js-screenshot-for-npm

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

js_screen_shots

一个基于 JavaScript 的 DOM 截图工具。

star this repofork this repo npm MIT Licence

如何使用

1.安装

# 使用npm安装
npm install --save js_screen_shots

2.导入

import all from '../node_modules/js_screen_shots'
console.log(all);
// {html2canvas: ƒ, Canvas2Image: {…}}
// Canvas2Image: {saveAsImage: ƒ, saveAsPNG: ƒ, saveAsJPEG: ƒ, saveAsGIF: ƒ, saveAsBMP: ƒ, …}
// html2canvas: ƒ html2canvas(element, conf)

3.使用

可以看见all对象里面有两个方法:html2canvas和Canvas2Image。
html2canvas的作用是把html标签转化为canvas元素。
Canvas2Image的作用是把canvas元素转化为img元素。

参考文档

html2canvas文档
Canvas2Image文档