当前位置: 首页 > 工具软件 > src2png > 使用案例 >

png图片转base64

吕飞翼
2023-12-01
<img id='iii' @load="abc"  src="../aseets/bottom.png"  >
<canvas id="canvas"></canvas>





abc(){

   var canvas=document.getElementById('canvas')
   var img=document.getElementById('iii)
   var ctx=canvas.getContext("2d")
   var height=img.height
   var width=img.width
   canvas.width=width
   canvas.height=height

   ctx.drawImage(img,0,0,width.height)
   let dataUrl=canvas.toDataURL('image/png",1)
   console.log(dataUrl)
}

 类似资料: