biji/前端/前端通过页面(dom)生成图片并下载保存.md
2020-02-07 18:37:52 +08:00

16 lines
611 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

> 遇到一个需要生成海报的需求但是海报又过于复简单的canvas实现太麻烦所以想直接通过dom生成图片。
## 初始准备
用到的库有三个
- ```jquery```
- ```html2canvas```
- ```Canvas2Image```
中间还尝试过一次```dom-to-image```但是出现了错误,没发使用,所以换到了```html2canvas```
## 下载引用
[jquery](https://jquery.com/)
[html2canvas](http://html2canvas.hertzen.com/)
[Canvas2Image](https://github.com/hongru/canvas2image)
引用过程就不做过多描述了
## 使用
页面现在默认已经写好了,通过页面进行生成了