This commit is contained in:
pplokijuhyg 2020-02-07 18:40:52 +08:00
parent e078f996a1
commit 3fc72d3fe7

View File

@ -13,19 +13,7 @@
## 使用
页面现在默认已经写好了,通过页面进行生成了
```
$(".download").click(() => {
new html2canvas(document.getElementById('app'), {
allowTaint: true,
taintTest: true,
useCORS: true,
background: null,
windowWidth:document.body.scrollWidth,
windowHeight:document.body.scrollHeight,
x:(document.body.scrollWidth - width)/2,
y:0
}).then(canvas => {
let imgUrl = Canvas2Image.convertToPNG(canvas,$("#app").width(),$("#app").height())
imgUrl = $(imgUrl).attr('src')
function downloadimg(){
// 如果浏览器支持msSaveOrOpenBlob方法也就是使用IE浏览器的时候那么调用该方法去下载图片
if (window.navigator.msSaveOrOpenBlob) {
var bstr = atob(imgUrl.split(',')[1])
@ -43,6 +31,20 @@ $(".download").click(() => {
a.setAttribute('download', new Date().getTime() + '.png')
a.click()
}
}
$(".download").click(() => {
new html2canvas(document.getElementById('app'), {
allowTaint: true,
taintTest: true,
useCORS: true,
background: null,
windowWidth:document.body.scrollWidth,
windowHeight:document.body.scrollHeight,
x:(document.body.scrollWidth - width)/2,
y:0
}).then(canvas => {
let imgUrl = Canvas2Image.convertToPNG(canvas,$("#app").width(),$("#app").height())
imgUrl = $(imgUrl).attr('src')
});
})
```