网友回复
很简单
var mySvg = document.querySelector(".mysvg");
var svgCon = mySvg.outerHTML;
//svg转base64;
alert(window.btoa(unescape(encodeURIComponent(svgCon))));
完整代码如下:
<!DOCTYPE html>
<html>
<head>
<title>svgAsHtml</title>
<meta charset="utf-8">
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/d3.js"></script>
</head>
<body>
<svg width="300" height="170" class="mysvg" viewbox="0 0 300 170" xmlns="http://www.w3.org/2000/svg" version="1.1">
<path d="M100 10 L50 60 L150 60 Z" stroke="#FB716D" stroke-width="3" fill="#FBA28A" />
<rect x="55" y="61" width="90" height="100" fill="#F3C392"></rect>
<rect x="85" y="97" width="30" height="30" stroke="#f6f6f6" stroke-width="3" fill="#B2DBCB" />
<line x1="85" x2="115" y1="112" y2="112" stroke="#f6f6f6" stroke-width="3" fill="transparent" />
<line x1="100" x2="100" y1="97" y2="127" stroke="#f6f6f6" stroke-width="3" fill="transparent" />
<g transform="translate(150,-18)">
<path d="M 30 160 A 30 35, 0, 1, 1, 60 160 L 45 160 Z" fill="#7ACB9E"></path>
<rect x="40" y="160" width="10" height="22" fill="#EBBEA6" />
</g>
<g transform="translate(187,-18)">
<path d="M70 100 L40 160 L100 160 Z" fill="#7ACB9E" />
<rect x="65" y="160" width="10" height="22" fill="#EBBEA6" />
</g>
</svg>
<script type=...点击查看剩余70%
如何用python实现一个公网代理访问软件?
如何用go实现一个公网代理访问软件?
如何用python实现一个内网穿透打洞程序,实现内网的80端口暴露到公网上可以访问?
如何用go实现一个内网穿透打洞程序,实现内网的80端口暴露到公网上可以访问?
何为Shadowsocks 代理?
python如何实现类似php的opendir目录相互隔离的fastcgi多租户虚拟空间?
nodejs如何实现类似php的opendir目录相互隔离的fastcgi多租户虚拟空间?
如何用html写出网页滚动视频播放卡片视觉差异效果的代码?
程序员如何低成本搭建代理进行科学上网学习技术?
threejs如何做个三维搭积木的游戏?


