网友回复
很简单
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%
在哪可以免费白嫖claude 4.5?
如何编写一个chrome插件实现多线程高速下载大文件?
cdn版本的vue在网页中出现typeerror错误无法找到错误代码位置怎么办?
pywebview能否使用webrtc远程控制共享桌面和摄像头?
pywebview6.0如何让窗体接受拖拽文件获取真实的文件路径?
如何在linux系统中同时能安装运行apk的安卓应用?
python有没有离线验证码识别ocr库?
各家的ai图生视频及文生视频的api价格谁最便宜?
openai、gemini、qwen3-vl、Doubao-Seed-1.6在ui截图视觉定位这款哪家更强更准?
如何在linux上创建一个沙箱隔离的目录让python使用?