问题描述
我试图从codepen复制以下代码:尝试在我的本地主机上运行它。在codepen中,你可以看到签名是动画的。但是,在我的本地机器上,它只是完整地打印签名,并且完全不带动画。任何想法为什么?
我在本地主机index.html(包含SVG代码).js.js,style.css(代码如下)上有三个文件。我尝试使用MAMP以查看它是否可行,但仍然只是打印出没有动画的名称。这是我的签名如何导入其他两个文件:
< head>
< link rel =stylesheettype =text / csshref =style.css>
< / head>< body>< script src =js.js>< / script>
< div class =container> < div class =signature> SVG CODE< / div>< / div>< / body>
谢谢!
似乎有两个问题:
1)缺少jQuery,它依赖于javascript < script src =https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js> ;< / script>
$ b 2)从codepen复制javascript时,它在编译coffeescript时添加了一些附加检查。因此,只需使用将coffeescript转换为javascript预览,然后即可使用它在你的代码中。
在完成这两件事之后,代码为我完美地工作。谢谢@Guy的帮助
I tried to copy the following code from codepen http://codepen.io/ghepting/pen/xnezB to try and run it on my localhost machine. In codepen, as you can see the signature is animated. However, on my local machine it just print the signature out in full and does not animate at all. Any idea why?
I have three files on my local host machine index.html (contains SVG code).js.js, style.css (code below). I tried using MAMP as well to see if it would work however still just prints out the name without animating. This is how my signature imports the other two files:<head><link rel="stylesheet" type="text/css" href="style.css"></head><body><script src="js.js"></script><div class="container"> <div class="signature"> SVG CODE </div></div></body>
Any idea what could be the issue? Thank you!
Seems like there were two problems:
1) missing jQuery which is a dependancy for the javascript <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
2)While copying javascript from codepen, it was adding some addition checks whilst compiling the coffeescript. So just use http://js2.coffee/ in order to convert the coffeescript into javascript preview, which you can then use in your code.
After fixinf these two things, the code worked perfectly for me. Thank you @Guy for your help
这篇关于自定义SVG签名在CODEPEN上运行,但不在本地计算机上 - 出了什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!