update
This commit is contained in:
parent
e078f996a1
commit
3fc72d3fe7
@ -13,19 +13,7 @@
|
|||||||
## 使用
|
## 使用
|
||||||
页面现在默认已经写好了,通过页面进行生成了
|
页面现在默认已经写好了,通过页面进行生成了
|
||||||
```
|
```
|
||||||
$(".download").click(() => {
|
function downloadimg(){
|
||||||
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')
|
|
||||||
// 如果浏览器支持msSaveOrOpenBlob方法(也就是使用IE浏览器的时候),那么调用该方法去下载图片
|
// 如果浏览器支持msSaveOrOpenBlob方法(也就是使用IE浏览器的时候),那么调用该方法去下载图片
|
||||||
if (window.navigator.msSaveOrOpenBlob) {
|
if (window.navigator.msSaveOrOpenBlob) {
|
||||||
var bstr = atob(imgUrl.split(',')[1])
|
var bstr = atob(imgUrl.split(',')[1])
|
||||||
@ -43,6 +31,20 @@ $(".download").click(() => {
|
|||||||
a.setAttribute('download', new Date().getTime() + '.png')
|
a.setAttribute('download', new Date().getTime() + '.png')
|
||||||
a.click()
|
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')
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
```
|
```
|
Loading…
Reference in New Issue
Block a user