Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

前端能否读取SVG文件的代码内容?

现有一需求,用户上传一个.svg文件后,要显示该svg文件的代码内容以供复制,svg的节点代码内容不保存进数据库。
前端能否在只有svg的服务器路径的情况下解析得到其结点代码内容?如何实现?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

用一个div把这个svg包裹起来,$('div').innerHtml获取


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...