我使用的是ASP.MVC,我需要使用spin.js,但不起作用。这是我正在使用的代码。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>spin.js example</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/spin.js/1.2.7/spin.min.js"></script>
</head>
<body>
<div id="foo"></div>
<script>
var opts = {
lines: 10, // The number of lines to draw
length: 7, // The length of each line
width: 4, // The line thickness
radius: 10, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 0, // The rotation offset
color: '#000', // #rgb or #rrggbb
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: 25, // Top position relative to parent in px
left: 25 // Left position relative to parent in px
};
var target = document.getElementById('foo');
var spinner = new Spinner(opts).spin(target);
</script>
</body>
</html>但是当我运行它时,这一行显示了一个异常。
var spinner = new Spinner(opts).spin(target);传达的信息是
“旋转器未定义”
我有什么办法解决这个问题吗?
发布于 2014-10-16 21:53:27
使用spin库的完全限定路径,当插入到StackOverflow代码片段中时,它似乎工作得很好(实际上是复制了您的问题,没有额外的修改)。这可能指向您的代码中的其他问题(这是整个页面),或者您的浏览器缓存了导致问题的东西。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>spin.js example</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/spin.js/1.2.7/spin.min.js"></script>
</head>
<body>
<div id="foo"></div>
<script>
var opts = {
lines: 10, // The number of lines to draw
length: 7, // The length of each line
width: 4, // The line thickness
radius: 10, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 0, // The rotation offset
color: '#000', // #rgb or #rrggbb
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: 25, // Top position relative to parent in px
left: 25 // Left position relative to parent in px
};
var target = document.getElementById('foo');
var spinner = new Spinner(opts).spin(target);
</script>
</body>
</html>
发布于 2014-10-16 21:39:01
尝试使用绝对url (使用类似于http的方案)。
<script src="http://cdnjs.cloudflare.com/ajax/libs/spin.js/1.2.7/spin.min.js"/>希望这能帮上忙。
https://stackoverflow.com/questions/26414320
复制相似问题