简体   繁体   English

Snap.SVG附加SVG元素

[英]Snap.SVG attaching SVG elements

I'm trying to insert an SVG using snap.svg, to a page and then have it rotate and expand slightly. 我正在尝试使用snap.svg将SVG插入页面,然后使其旋转并稍微扩展。 I'm using brackets at the moment as some local live preview thing, and the problem I'm having is twofold; 我现在使用括号作为一些本地实时预览的东西,而我遇到的问题是双重的。 I managed to get it in place about half an hour ago and then broke it somehow and now I don't know how to get it back, and the syntax for snap.svg is condensed enough to make it kind of iffy to read, and the documentation isn't very good, so I'm unable to work out how exactly I do what I want to do. 大约半小时前,我设法将其安装到位,然后以某种方式将其折断,现在我不知道如何将其取回,而且snap.svg的语法已经压缩到足以使它难以阅读了,并且文档不是很好,所以我无法确定我要做什么的精确程度。 I gave search a go, but the callback method I found doesn't seem to be working. 我试了一下搜索,但是发现的回调方法似乎不起作用。 Can anybody help? 有人可以帮忙吗?

<!DOCTYPE html>
    <html>


    <body>
    <script src="snap.svg-min.js"></script>

    <script type="text/javascript">
        var paper = Snap(500,500),
        Snap.load('ringing-phone.svg', function (phone) {
        phone.selectAll("path[fill='#ff0000']").attr({fill: "#00ff00"});
        var g = phone.select("g");
    });
        </script>



    </body>


    </html>

You have a naughty comma after the var paper line, it should be a semicolon, as you aren't defining a variable on the next line. var纸行后有一个顽皮的逗号,它应该是分号,因为您没有在下一行定义变量。

var paper = Snap(500,500); //<-- this semicolon
Snap.load('ringing-phone.svg', ....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM