htmlToCanvas(area){
let that=this
this.isPrint=true
let name='面试维度.png'
return new Promise((res,rej)=>{
setTimeout(()=>{
html2canvas(area,{
width:area.clientWidth,
height:area.clientHeight,
scale: 1,
useCORS:true,
}).then(canvas => {
res(canvas)
})
},300)
})
},
download() {
let that=this
this.isPrint=true
let name='面试维度.png'
setTimeout(()=>{
this.htmlToCanvas(this.$refs.downAreaWrap2).then(canvas=>{
if(that.isIEOrEdge()){
let blob = canvas.msToBlob();
navigator.msSaveBlob(blob,name);
that.isPrint=false
} else {
let link=document.createElement('a')
link.href=canvas.toDataURL()
link.download = name
link.style.display='none'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
that.isPrint=false
}
})
},300)
},
html2canvas绘图
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 需求:将后台返回的内容,前端拼接成一个整体的图片(模仿截图的效果) 解决:html2canvas插件,截图操作 插...
- 项目中需要在微信中生成海报图,用户长按海报图后可以将图片发送给微信好友或保存到本地; 海报图在前端使用html2c...
- 本周有个需求是将HTML渲染好的页面生成图片,用户在微信端使用的时候能够保存到相册。于是一顿搜索猛如虎之后,发现h...
- 第一步:先引入对应的js,我引用的是老版本的,对应的js放在文章结尾了包含了这两个js(js版本也很重要哦,每个版...
- 之前在网上找到一个用 的 download属性下载的方法,确实很简单也很方便,但此方法不支持IE,无奈又找到另...