滑块数据在带有后端数据的引导程序中无法正常工作

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了滑块数据在带有后端数据的引导程序中无法正常工作相关的知识,希望对你有一定的参考价值。

您好,我将后端的数据显示到滑块中,但响应不佳,最初是这样的“”

并且向左滑动,但现在像这样

“”

一次显示所有数据。我想在下一张幻灯片上显示其他数据我正在使用此滑块

https://codepen.io/kravisingh/pen/pLGzgo

代码:

  <div class="carousel-item active">
       <% meetings.forEach(function(meeting) %>
            <div class="col-xs-3 col-sm-3 col-md-3">
                 <div class="col-md-2 col-xs-12 upcoming-btn">
                      <span href="" class="btn btn-success btn-lg dashboard-icon" style="width: 200px; height: 150px;">
                          <p style="padding-top: 15px; font-size: 25px;
                                                        font-weight: bold;"><%= meeting.subject %></p>
                          <p style="font-size: 25px; font-weight: bold;"><%= convertDate(meeting.date) %></p>
                          <p style="font-size: 25px; font-weight: bold;">Upcoming</p>
                        </span>
                     </div> 
                   </div> 
                 <% ) %>   
               </div>

完整的滑块代码:

.col-md-3 
  display: inline-block;
  margin-left: -4px;


.col-md-3 img 
  width: 100%;
  height: auto;


body .carousel-indicators li 
  background-color: red;


body .carousel-control-prev-icon,
body .carousel-control-next-icon 
  background-color: red;


body .no-padding 
  padding-left: 0;
  padding-right: 0;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<div id="demo" class="carousel slide" data-ride="carousel">

  <!-- Indicators -->
  <ul class="carousel-indicators">
    <li data-target="#demo" data-slide-to="0" class="active"></li>
    <li data-target="#demo" data-slide-to="1"></li>
    <li data-target="#demo" data-slide-to="2"></li>
  </ul>

  <!-- The slideshow -->
  <div class="container carousel-inner no-padding">
    <div class="carousel-item active">
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
    </div>
    <div class="carousel-item">
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
    </div>
    <div class="carousel-item">
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
      <div class="col-xs-3 col-sm-3 col-md-3">
        <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
      </div>
    </div>
  </div>

  <!-- Left and right controls -->
  <a class="carousel-control-prev" href="#demo" data-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </a>
  <a class="carousel-control-next" href="#demo" data-slide="next">
    <span class="carousel-control-next-icon"></span>
  </a>
</div>
答案

将s放在页面末尾,紧接在结束标记之前,以启用它们,然后使用此方法:

<div id="demo" class="carousel slide" data-ride="carousel">

    <!-- Indicators -->
    <ul class="carousel-indicators">
        <li data-target="#demo" data-slide-to="0" class="active"></li>
        <li data-target="#demo" data-slide-to="1"></li>
        <li data-target="#demo" data-slide-to="2"></li>
    </ul>

    <!-- The slideshow -->
    <div class="container carousel-inner no-padding">
        <div class="carousel-item active">
           <div class="row">
               <div class="col-xs-3 col-sm-3 col-md-3">
                   <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg"  class="img-fluid">
               </div>
               <div class="col-xs-3 col-sm-3 col-md-3">
                   <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg"  class="img-fluid">
               </div>
               <div class="col-xs-3 col-sm-3 col-md-3">
                   <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg"  class="img-fluid">
               </div>
               <div class="col-xs-3 col-sm-3 col-md-3">
                   <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg"  class="img-fluid">
               </div>
           </div>
        </div>
        <div class="carousel-item">
           <div class="row">
               <div class="col-xs-3 col-sm-3 col-md-3">
                   <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg" class="img-fluid">
               </div>
               <div class="col-xs-3 col-sm-3 col-md-3">
                   <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg" class="img-fluid">
               </div>
               <div class="col-xs-3 col-sm-3 col-md-3">
                   <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg" class="img-fluid">
               </div>
               <div class="col-xs-3 col-sm-3 col-md-3">
                   <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg" class="img-fluid">
               </div>
           </div>
        </div>
        <div class="carousel-item">
            <div class="row">
                <div class="col-xs-3 col-sm-3 col-md-3">
                    <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg"  class="img-fluid">
                </div>
                <div class="col-xs-3 col-sm-3 col-md-3">
                    <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg"  class="img-fluid">
                </div>
                <div class="col-xs-3 col-sm-3 col-md-3">
                    <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg"  class="img-fluid">
                </div>
                <div class="col-xs-3 col-sm-3 col-md-3">
                    <img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg"  class="img-fluid">
                </div>
            </div>
        </div>
    </div>

    <!-- Left and right controls -->
    <a class="carousel-control-prev" href="#demo" data-slide="prev">
        <span class="carousel-control-prev-icon"></span>
    </a>
    <a class="carousel-control-next" href="#demo" data-slide="next">
        <span class="carousel-control-next-icon"></span>
    </a>
</div>


以上是关于滑块数据在带有后端数据的引导程序中无法正常工作的主要内容,如果未能解决你的问题,请参考以下文章

Yii2 后端引导树视图 url 无法正常工作

带有滚动正文的引导固定表头

带引导模态的数据表(模态不工作)

引导数据表无法与 thymeleaf th:block 一起正常工作

使用 ajax json 加载数据后,引导数据表无法正常工作

引导网站中的滑块图像不适合移动视图