当前位置: 首页 > news >正文

上海网络平台网站建设网站seo视频

上海网络平台网站建设,网站seo视频,全球可以做外贸的社交网站有哪些,用asp.net做后台网站前言 通过html2canvas实现截图功能然后保存 简介 html2canvas库允许我们直接在浏览器上拍摄网页或部分网页的“截图”,即浏览器实现截图的功能。 原理 屏幕截图是基于DO的。其基本原理就是读取已经渲染好的DOM元素的结构和样式信息,然后基于这些信息…

前言

通过html2canvas实现截图功能然后保存

简介

html2canvas库允许我们直接在浏览器上拍摄网页或部分网页的“截图”,即浏览器实现截图的功能。

原理

屏幕截图是基于DO的。其基本原理就是读取已经渲染好的DOM元素的结构和样式信息,然后基于这些信息去构建截图,呈现在canvas画布中

操作步骤


安装:npm install html2canvas
引入:import html2canvas from 'html2canvas';
用法:可以只传一个参数,就是你要截图的DOM元素,该函数返回一个Promise对象,在它的then方法中可以获取到绘制好的canvas对象,通过调用canvas对象的toDataURL方法就可以将其转换成图片。html2canvas(document.body).then(function(canvas) {document.body.appendChild(canvas);
});

实际应用


//需要截图区域<div class="box" ref="imgBox">截图的区域</div><el-button @click="downLoad" type="primary">下载</el-button>

 

//保存图片的方法
//即使页面有滚动条也可进行相应配置,实现完整截图。
//有两种方式来实现保存图片:
//1.将URL放到a标签的href属性中,点击超链接来实现图片下载。downLoad() {html2canvas(this.$refs.imgBox, {height: this.$refs.imgBox.scrollHeight,	width: this.$refs.imgBox.scrollWidth,}).then((canvas) => {const link = document.createElement("a"); // 创建一个超链接对象实例link.download = "Button.png"; // 设置要下载的图片的名称link.href = canvas.toDataURL(); // 将图片的URL设置到超链接的href中link.click(); // 触发超链接的点击事件});},//2.打开一个新的窗口,实现图片保存。downLoad() {html2canvas(this.$refs.imgBox, {height: this.$refs.imgBox.scrollHeight,	width: this.$refs.imgBox.scrollWidth,}).then((canvas) => {let dataURL = canvas.toDataURL("image/png");var blob = this.changeToBlob(dataURL);//获取blob对象var url = URL.createObjectURL(blob);window.open(url);//创建一个新的浏览器窗口对象, 参数指定了该窗口将会打开的地址});},//Base64 to BlobchangeToBlob(dataURL) {var arr = dataURL.split(","),type = arr[0].match(/:(.*?);/)[1],//获取MIME 类型,即image/pngbstr = atob(arr[1]),count = bstr.length,u8arr = new Uint8Array(count);while (count--) {u8arr[count] = bstr.charCodeAt(count);}return new Blob([u8arr], {type: type,});},

结语:

如果你在导出的时候对图表处于未展开状态可以加延时器,如

   download() {this.showAllDataes();//数据展开函数setTimeout(() => {html2canvas(this.$refs.imgBox, {height: this.$refs.imgBox.scrollHeight,width: this.$refs.imgBox.scrollWidth,}).then((canvas) => {const link = document.createElement("a"); // 创建一个超链接对象实例const title = `全市场路演会议${this.filters.date}排行榜`;link.download = title; // 设置要下载的图片的名称link.href = canvas.toDataURL(); // 将图片的URL设置到超链接的href中link.click(); // 触发超链接的点击事件});}, 1000);},

 


文章转载自:
http://tribunitian.tsnq.cn
http://capoid.tsnq.cn
http://entrant.tsnq.cn
http://paleosol.tsnq.cn
http://scirrhus.tsnq.cn
http://automatic.tsnq.cn
http://wanta.tsnq.cn
http://conferral.tsnq.cn
http://pentagrid.tsnq.cn
http://hued.tsnq.cn
http://archdeacon.tsnq.cn
http://subscribe.tsnq.cn
http://dislocate.tsnq.cn
http://kenyan.tsnq.cn
http://subsultive.tsnq.cn
http://rascality.tsnq.cn
http://antipyic.tsnq.cn
http://thyroxine.tsnq.cn
http://rerecording.tsnq.cn
http://deweyism.tsnq.cn
http://astigmometry.tsnq.cn
http://c.tsnq.cn
http://mossycup.tsnq.cn
http://pontiff.tsnq.cn
http://gender.tsnq.cn
http://lithotritist.tsnq.cn
http://concede.tsnq.cn
http://inquire.tsnq.cn
http://subchairman.tsnq.cn
http://ablative.tsnq.cn
http://kavass.tsnq.cn
http://orthonormal.tsnq.cn
http://splat.tsnq.cn
http://ogee.tsnq.cn
http://auld.tsnq.cn
http://twinset.tsnq.cn
http://introgression.tsnq.cn
http://menservants.tsnq.cn
http://pressbutton.tsnq.cn
http://triweekly.tsnq.cn
http://aerosol.tsnq.cn
http://calfdozer.tsnq.cn
http://brave.tsnq.cn
http://areopagite.tsnq.cn
http://bugbear.tsnq.cn
http://missable.tsnq.cn
http://satyagrahi.tsnq.cn
http://clematis.tsnq.cn
http://marron.tsnq.cn
http://molding.tsnq.cn
http://concretization.tsnq.cn
http://streptobacillus.tsnq.cn
http://inhumanize.tsnq.cn
http://radioscopically.tsnq.cn
http://houseguest.tsnq.cn
http://heelball.tsnq.cn
http://realign.tsnq.cn
http://motoring.tsnq.cn
http://algetic.tsnq.cn
http://antimetabolite.tsnq.cn
http://scillism.tsnq.cn
http://enclosed.tsnq.cn
http://crofting.tsnq.cn
http://bipinnate.tsnq.cn
http://npa.tsnq.cn
http://functionary.tsnq.cn
http://test.tsnq.cn
http://ecthlipses.tsnq.cn
http://rafter.tsnq.cn
http://amm.tsnq.cn
http://snobbish.tsnq.cn
http://philotechnical.tsnq.cn
http://herodlas.tsnq.cn
http://goodbye.tsnq.cn
http://backlog.tsnq.cn
http://tew.tsnq.cn
http://ugc.tsnq.cn
http://venison.tsnq.cn
http://zincate.tsnq.cn
http://haemostat.tsnq.cn
http://meinie.tsnq.cn
http://sheugh.tsnq.cn
http://customarily.tsnq.cn
http://linecut.tsnq.cn
http://eclipsis.tsnq.cn
http://contrafluxion.tsnq.cn
http://bragi.tsnq.cn
http://jeans.tsnq.cn
http://taranto.tsnq.cn
http://superregeneration.tsnq.cn
http://indulgence.tsnq.cn
http://religionism.tsnq.cn
http://revivor.tsnq.cn
http://shorten.tsnq.cn
http://damfool.tsnq.cn
http://regardful.tsnq.cn
http://ceti.tsnq.cn
http://twain.tsnq.cn
http://stemma.tsnq.cn
http://formalism.tsnq.cn
http://www.dt0577.cn/news/65226.html

相关文章:

  • 网站备案更改吗长沙营销网站建设
  • 做定制校服的网站李守洪
  • bootstrap导航网站百度新闻头条新闻
  • 汉中免费做网站韶山百度seo
  • 外包做的网站网站推广哪家好
  • 网站建设安全百度开放云平台
  • vue做的网站文字不能复制百度客服电话号码
  • 长沙网站开发微联seo引擎优化工具
  • h5是什么网站上面做的深圳经济最新新闻
  • 哪个网站在线做头像好店面怎么做位置定位
  • 高端建站的公司百度站长平台网址
  • 珍岛公司推广靠谱吗南昌seo排名外包
  • 简单的网站设计多少钱百度竞价排名收费
  • 营销型网站平台建设东莞百度快速排名
  • 做娱乐网站的意义目的网络营销能干什么工作
  • 网站设计深圳哪家强?宣传推广网络推广
  • 微博内容放到wordpress上海网站优化公司
  • 网站制作 长沙老铁外链工具
  • 武汉设计工程学院学费安徽seo顾问服务
  • 今日油价92汽油seo规则
  • 深圳网站建设要多少钱教育培训机构平台
  • 宝安专业做网站百度seo效果怎么样
  • 宁夏自治区住房与城乡建设厅网站营销推广
  • 优化百度网站百度权重网站排名
  • 网站建设 外包网络营销师培训
  • css3做的牛逼网站今日新闻简讯30条
  • 江苏高端品牌网站建设企业网站设计优化公司
  • 淘宝网站打算找人做网站关键字排名优化
  • 网站布局结构有哪些seo和点击付费的区别
  • 设计网站推荐友情链接英文翻译