2016-11-13 113 views
1

我想在我的網站上安裝貓頭鷹旋轉木馬2,第一次使用這個,並遵循所有的insctructions我仍然有一些問題。貓頭鷹旋轉木馬返回錯誤

進口後的所有文件:

<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> 

控制檯回報S:

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(…) 

而且我也沒有IDEIA爲什麼它返回這個錯誤。

回答

0

同樣的問題在這裏。我嘗試使用舊版本的jQuery,它工作得很好。嘗試使用舊版本的jQuery。

1

問題是在老版本的jQuery中缺少andSelf函數。嘗試添加到您的.js文件以下

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

.andSelf()在jQuery 1.8中被棄用,並在jQuery 3.0中被刪除。 .addBack()應該用於jQuery 1.8以上版本。

所以對於一個快速和骯髒的修復,在您的owl.caorusel.min.js文件,只需用「後加入」取代「andSelf」,它會工作。