我設法解決這個問題我想最初的方式。 這裏是萬一有人的代碼有同樣的問題:
的Javascript:
<script>
$(document).ready(function(){
$("#myCarousel").carousel();
// Enable Carousel Indicators
$(".item1").click(function(){
$("#myCarousel").carousel(0);
// The next line of code triggers the listeners for the page-resizing
// event, which includes the carousel and will display the chart
// correctly.
window.dispatchEvent(new Event('resize'));
});
$(".item2").click(function(){
$("#myCarousel").carousel(1);
window.dispatchEvent(new Event('resize'));
});
});
</script>
HTML:
<ol class="carousel-indicators carousel-indicators-numbers">
<li class="item1 active">1</li>
<li class="item2" >2</li>
</ol>