解决以下问题时遇到问题

时间:2018-09-06 10:03:33

标签: javascript jquery html css

尝试此代码

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Owl Carousel</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <link rel="stylesheet" href="owlcarousel/owl.carousel.min.css">
        <link rel="stylesheet" href="owlcarousel/owl.theme.default.min.css">
    </head>
    <body>
        <div class="owl-carousel">
            <div> Your Content </div>
            <div> Your Content </div>
            <div> Your Content </div>
            <div> Your Content </div>
            <div> Your Content </div>
            <div> Your Content </div>
            <div> Your Content </div>
        </div>
        <script>
            $(document).ready(function(){
                $(".owl-carousel").owlCarousel();
            });
        </script>
        <script src="jquery.min.js"></script>
        <script src="owlcarousel/owl.carousel.min.js"></script>
    </body>
</html>

我正在尝试在新项目中使用owl carousel,但似乎owl carousel无法正常工作,我尝试使用以上代码不知道即时通讯出了问题,请任何人帮助我,以便它会有所帮助我要解决此问题,因为我是该领域的新手,无法解决该问题,所以任何人都可以在此帮助我

1 个答案:

答案 0 :(得分:4)

从最后删除<script src="jquery.min.js"></script>

并按如下所示初始化Carousel

jQuery(document).ready(function() {
  jQuery(".owl-carousel").owlCarousel({
  });
});

或尝试使用此代码

jQuery(document).ready(function() {
  jQuery(".owl-carousel").owlCarousel({});
});
<!DOCTYPE html>
<html lang="en">

<head>
  <title>Owl Carousel</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.theme.min.css">
</head>

<body>
  <div class="owl-carousel">
    <div> Your Content </div>
    <div> Your Content </div>
    <div> Your Content </div>
    <div> Your Content </div>
    <div> Your Content </div>
    <div> Your Content </div>
    <div> Your Content </div>
  </div>


  <script src="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.js"></script>
</body>

</html>