2016-11-23 52 views
2

不行我使用引導旋轉木馬在SPA使用此代碼。我是新的自舉旋轉木馬「下一步」,「上一頁」功能在單頁應用SPA

<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> 

但是當我點擊NextPrev是找到#myCarousel頁面箭頭按鈕,而顯示下一張幻燈片。請幫我做什麼。

+0

A.任何錯誤'? B.你應該叫'$( 「#myCarousel」)轉盤();'後,一旦轉盤添加到DOM。嘗試一下,讓我知道。 –

回答

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> 
2

我解決這個問題消除href的值,並添加

數據目標=「#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>

+0

解決了我的問題。不知道爲什麼。 –