【发布时间】:2020-12-17 22:38:00
【问题描述】:
我正在尝试实现 JQuery 计数器插件,但出现错误:
dashboard:694 Uncaught TypeError: $(...).counterUp 不是函数
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"integrity="sha384q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.3/waypoints.min.js"></script>
<script src="jquery.counterup.min.js"></script>
</head>
<body>
<div class="task-stat"><i class="icon-tasks"></i>Total tasks today<br><h2><span class="counter" data-counterup-time="1500" data-counterup-delay="30" data-counterup-beginat="100">{{$tasks->count()}}</span></h2></div>
<script>
$('.counter').counterUp({
delay: 10,
time: 1000,
offset: 70,
beginAt: 100,
formatter: function (n) {
return n.replace(/,/g, '.');
}
});
</script>
</body>
</html>
【问题讨论】:
-
可能路径错误
<script src="jquery.counterup.min.js"></script>,可能看起来应该像<script src="assets/js/jquery.counterup.min.js"></script>。这取决于您的项目目录树 -
问题解决了吗?
标签: javascript jquery