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

后端 未结 4 2040
执念已碎
执念已碎 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 20:07

    You could check the number of .item elements before you call your plugin like so:

    // Be more specific with your selector if .items is used elsewhere on the page. 
    var items = $('.items');
    if(items.length > 1) {
        $('#owl-demo').owlCarousel({
            loop: true,
            ...
        });
    } else {
        // same as above but with loop: false;
    }
    

提交回复
热议问题