owl carousel 2 not work with loop and 1 items (Bug Fixed Now)

后端 未结 4 2039
执念已碎
执念已碎 2021-02-15 19:40

I work with owl carousel 2 for carousel content.

JS:

$(\'#owl-demo\').owlCarousel({
    loop: true,
    margin: 10,
    nav: true,
    items: 1,
});
         


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-02-15 19:58

    I used this method to solve the problem and I think it's pretty easy.

    var options={
        margin: 10,
        nav: true,
        items: 1
        };
       if($('#owl-demo .owl-item').length>1){
           options.loop=true;
       }
       $('#owl-demo').owlCarousel(options);
    

提交回复
热议问题