svg.js如何将SVG添加到HTML页面
我有一个页面,该页面将显示几个将从JSON数据生成的SVG图像。我创建了一个将生成SVG的JavaScript类,但我不知道如何将其添加到DOM中。
作为一个简单的例子:
<html>
<body>
<div class="myrow">
*i want to add the image here*
</div>
</body>
</html
我尝试了类似的事情:
let x = new mysvgobject(json);
x.img.addTo('.myrow');
但是它不起作用。我认为我需要将X.img转换为HTML会理解的东西,但不知道那是什么。任何帮助将不胜感激。
I have a page that will show several svg images that will be generated from json data. I created a javascript class that will generate the svg but I don't know how to add it to the dom.
As a simple example:
<html>
<body>
<div class="myrow">
*i want to add the image here*
</div>
</body>
</html
I tried something like:
let x = new mysvgobject(json);
x.img.addTo('.myrow');
but it doesn't work. I think I need to convert that x.img to something the HTML will understand but don't know what that might be. Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到答案。只需要进一步钻入班级生产的SVG,
然后将其放在页面上。
Found the answer. Just had to drill down further into the svg produced by the class with:
and drop it on the page.