gpt4 book ai didi

javascript - Owl Carousel 返回错误

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

我正在尝试在我的网站上安装 Owl Carousel 2,这是我第一次使用它,并且按照所有说明进行操作后我仍然遇到一些问题。

导入所有文件后:

<head>
<meta charset="utf-8">
<title>The badass man alive</title>
<!-- CSS -->
<link rel="stylesheet" href="assets/vendors/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/vendors/owl-carousel/assets/owl.carousel.css">
<!-- Javascript -->
<script src="assets/vendors/jQuery/jquery-3.1.1.min.js" type="text/javascript"></script>
<script src="assets/vendors/owl-carousel/owl.carousel.min.js" type="text/javascript"></script>
<script src="assets/js/script.js" type="text/javascript"></script>

添加演示javascript代码:

$(function() {
$('.owl-carousel').owlCarousel({
loop:true,
margin:10,
nav:true,
responsive:{
0:{
items:1
},
600:{
items:3
},
1000:{
items:5
}
}
});
});

并尝试加载示例文件:

<div class="owl-carousel">
<div class="item"><h4>1</h4></div>
<div class="item"><h4>2</h4></div>
<div class="item"><h4>3</h4></div>
<div class="item"><h4>4</h4></div>
<div class="item"><h4>5</h4></div>
<div class="item"><h4>6</h4></div>
</div>

控制台返回这个:

jQuery.Deferred exception: a(...).find(...).andSelf is not a function TypeError: a(...).find(...).andSelf is not a function
at c.<anonymous> (file:///.../assets/vendors/owl-carousel/owl.carousel.min.js:2:7592)
at HTMLDivElement.e (file:///.../assets/vendors/jQuery/jquery-3.1.1.min.js:2:3655)
at HTMLDivElement.dispatch (file:///.../assets/vendors/jQuery/jquery-3.1.1.min.js:3:10315)
at HTMLDivElement.q.handle (file:///.../assets/vendors/jQuery/jquery-3.1.1.min.js:3:8342)
at Object.trigger (file:///.../assets/vendors/jQuery/jquery-3.1.1.min.js:4:5808)
at HTMLDivElement.<anonymous> (file:///.../assets/vendors/jQuery/jquery-3.1.1.min.js:4:6318)
at Function.each (file:///.../assets/vendors/jQuery/jquery-3.1.1.min.js:2:2815)
at r.fn.init.each (file:///.../assets/vendors/jQuery/jquery-3.1.1.min.js:2:1003)
at r.fn.init.trigger (file:///.../assets/vendors/jQuery/jquery-3.1.1.min.js:4:6294)
at e.trigger (file:///.../assets/vendors/owl-carousel/owl.carousel.min.js:1:22366) undefined
Uncaught TypeError: a(...).find(...).andSelf is not a function(…)

而且我不知道为什么会返回此错误。

最佳答案

问题在于旧版本的 jQuery 中缺少 andSelf 函数。尝试将以下内容添加到您的 .js 文件中

$.fn.andSelf = function() {
return this.addBack.apply(this, arguments);
}

关于javascript - Owl Carousel 返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40576523/

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