我使用此代码在SPA中使用Bootstrap Carousel。我是bootstrap的新手
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="false">
<!-- 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>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<a href="#discription" role="image">
<img src="cloth5.jpg" alt="Loading..." width="100%" height="auto">
</a>
</div>
<div class="item">
<img src="cloth5.jpg" alt="Loading..." width="460" height="345">
</div>
<div class="item">
<img src="menjeans.jpg" alt="Loading..." width="460" height="345">
</div>
<div class="item">
<img src="menjeans.jpg" alt="Loading..." width="460" height="345">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
但是当我点击查找页面Next
的{{1}}或Prev
箭头按钮时,会显示下一张幻灯片。请帮助我做。
答案 0 :(得分:2)
您是否使用<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<a href="#discription" role="image">
<img src="cloth5.jpg" alt="Loading..." width="100%" height="auto">
</a>
</div>
<div class="item">
<img src="cloth5.jpg" alt="Loading..." width="460" height="345">
</div>
<div class="item">
<img src="menjeans.jpg" alt="Loading..." width="460" height="345">
</div>
<div class="item">
<img src="menjeans.jpg" alt="Loading..." width="460" height="345">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
答案 1 :(得分:2)
我解决了这个问题,删除了href值并添加了
data-target =“#myCarousel
作为锚标记<a class="left carousel-control" href data-target="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href data-target="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>