猫头鹰旋转木马单品

问题描述

当我在 owl carousel 中使用单个项目时,循环不会停止。我希望它停止一个项目,当我添加其他项目时它会开始工作。以下是我的代码

$('.owl-carousel').owlCarousel({
loop:true,margin:10,nav:false,dots:false,responsive:{
    320:{
        stagePadding:11,items:1
    },425:{
        stagePadding:45,768:{
        items:2
    },1000:{
        items:3
    }
})

解决方法

如果没有看到您的其余代码就很难说 - 但是您可能应该以编程方式设置 loop,例如:

const numChildren = $('#container .child').length; // just an example
const isLooping = numChildren > 1;
$('.owl-carousel').owlCarousel({
    loop: isLooping,...
});