解决方法
将wrap选项设置为false会使轮播停止自动循环.
$('#myCarousel').carousel({ interval: 1000,wrap: false });
此外,如果您想在旋转木马显示第一张/最后一张幻灯片时隐藏左右控件,您可以这样做:
$('#myCarousel').on('slid.bs.carousel','',function() { var $this = $(this); $this.children('.carousel-control').show(); if($('.carousel-inner .item:first').hasClass('active')) { $this.children('.left.carousel-control').hide(); } else if($('.carousel-inner .item:last').hasClass('active')) { $this.children('.right.carousel-control').hide(); } });