Bootstrap轮播控件不能与node.js一起使用

问题描述 投票:0回答:1

创建一个航海网站,在推荐部分,左右控件和指示器没有响应。这是因为我没有在app.js中包含或调用该函数,或者我错过了一些jQuery? (使用.ejs)

我已经研究了slick-carousel-npm和其他软件包,在简单的HTML和CSS形式中代码也不起作用。

<section class="colouredSection">
  <div id="sectionContainer">

    <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">
            <h2 class="testimonial-text">"What a beautiful day! Our skipper was amazing and even taught us how to sail a bit. I would
              definitely recommend and repeat in the future!!! A perfect way to spend an afternoon in Barcelona."</h2>
        </div>
        <div class="item">
          <h2 class="testimonial-text">"What a beautiful day! Our skipper was amazing and even taught us how to sail a bit. I would
            definitely recommend and repeat in the future!!! A perfect way to spend an afternoon in Barcelona."</h2>
      </div>
        <div class="item">
          <h2 class="testimonial-text">"What a beautiful day! Our skipper was amazing and even taught us how to sail a bit. I would
            definitely recommend and repeat in the future!!! A perfect way to spend an afternoon in Barcelona."</h2>
      </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>
</section>
<!-- CSS -->
  <link rel="stylesheet" href="css/styles.css">
  <!-- Font Awesome -->
  <script defer src="https://use.fontawesome.com/releases/v5.0.7/js/all.js"></script>
  <!-- Google Fonts -->
  <link href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,800,800i|Special+Elite|Playfair+Display:400i" rel="stylesheet">
<!-- Bootstrap -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

在app.get(“/”中,我没有提到旋转木马。当我希望它通过航行旅行评论的幻灯片时没有响应。

html node.js bootstrap-4 carousel ejs
1个回答
0
投票

您需要在utils.js标签中的某处包含bootstrap.js<body>

最后,如果您从源代码构建JavaScript,则需要util.js.

https://getbootstrap.com/docs/4.0/components/carousel/

所有Bootstrap的JavaScript文件都依赖于util.js,它必须与其他JavaScript文件一起包含在内。如果你正在使用编译的(或缩小的)bootstrap.js,则不需要包含它 - 它已经存在了。

https://getbootstrap.com/docs/4.0/getting-started/javascript/#util

© www.soinside.com 2019 - 2024. All rights reserved.