hermitks

1.设定一个要生成海报的元素

<div id="viewBox" res="box">内容....</div>

2.引进js

Poster:function(){
	var that = this;
	var DomeW=that.$refs.box.offsetWidth;//获取目标元素的宽高
	var DemoH = that.$refs.box.offsetHeight;//获取目标元素的宽高
	html2canvas(document.querySelector("#viewBox"),{useCORS:true,width:DomeW,height:DemoH}).then(function(canvas) {
	var imgUri = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); // 获取生成的图片的url
	 console.log(imgUri );//生成图片base64
	})
},

分类:

技术点:

相关文章:

  • 2021-11-27
  • 2021-11-01
  • 2021-11-17
  • 2022-01-28
  • 2021-11-17
  • 2021-11-17
  • 2021-10-19
  • 2021-06-09
猜你喜欢
  • 2021-11-17
  • 2021-11-17
  • 2021-11-17
  • 2021-11-17
  • 2021-07-13
相关资源
相似解决方案