猫头鹰旋转木马单品

时间:2021-07-29 07:15:35

标签: javascript json javascript-objects jquery-events owl-carousel

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

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

1 个答案:

答案 0 :(得分:0)

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

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