gpt4 book ai didi

javascript - 使用 javascript spin.js 库时出错

转载 作者:行者123 更新时间:2023-11-30 17:14:14 30 4
gpt4 key购买 nike

我正在使用 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);

消息是

"Spinner is not defined"

关于如何解决这个问题有什么想法吗?

最佳答案

使用自旋库的完全限定路径,将此处插入 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>

关于javascript - 使用 javascript spin.js 库时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26414320/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com