Bootstrap 4轮播不工作?

Bootstrap 4 carousel not working?

我有以下 BS4 轮播代码,(使用本教程制作的 https://www.youtube.com/watch?v=n8ItscKLf7s&list=PLRtjMdoYXLf47brThg9-nTj8HSq8cQ0ND&index=53),但是代码不起作用,显示了第一张图片,但我不知道轮播不受控制的原因是什么,无论如何它都不会转到下一张图片。可能的解决方案是什么?

<div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
                <br />
                <div id="carousel-example-generic" class="carousel-slide" data-ride="carousel">
                    <ol class="carousel-indicators">
                    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"> </li>
                     <li data-target="#carousel-example-generic" data-slide-to="1"> </li>
                     <li data-target="#carousel-example-generic" data-slide-to="2"> </li>
                    </ol>

                    <div class="carousel-inner" role="listbox">
                        <div class="carousel-item-active">
                            <img src="images/1.jpeg" alt="First-Slide">
                        </div>
                        <div class="carousel-item">
                            <img src="images/2.jpeg" alt="Second-Slide">
                        </div>
                        <div class="carousel-item">
                            <img src="images/3.jpeg" alt="Third-Slide">
                        </div>
                    </div>
                    <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> 
                    <span class="icon-prev" aria-hidden="true"></span>
                    <span class="sr-only"> Previous </span>
                    </a>
                    <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> 
                    <span class="icon-next" aria-hidden="true"></span>
                    <span class="sr-only"> Next </span>
                    </a>
                </div>
            </div>
        </div>
    </div>

小错误。 class="carousel-item-active" 应该是 class="carousel-item active"。不是一个class。您已将 active class 与 carousel-item class 合并。那是错误的。

<div class="carousel-item-active">
  <img src="images/1.jpeg" alt="First-Slide">
</div>

应该改为

<div class="carousel-item active">
  <img src="images/1.jpeg" alt="First-Slide">
</div>

完美运行

<!DOCTYPE html>
<html lang="en">
<head>
  <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>
</head>
<body>

<div class="container">
  <div id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
      <li data-target="#myCarousel" data-slide-to="1"></li>
      <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner">
      <div class="item active">
        <img src="https://www.w3schools.com/bootstrap/ny.jpg" alt="Los Angeles" style="width:100%;">
      </div>

      <div class="item">
        <img src="https://www.w3schools.com/bootstrap/chicago.jpg" alt="Chicago" style="width:100%;">
      </div>
    
      <div class="item">
        <img src="https://www.w3schools.com/bootstrap/newyork.jpg" alt="New york" style="width:100%;">
      </div>
    </div>

    <!-- Left and right controls -->
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>
</div>

</body>
</html>