OwlCarousel2初始化多个实例的最佳方式是什么

问题描述:

我想要3个使用owlcarousel的滚动条(其中两个对它有不同的选项)。如何做到这一点最好(在表现意义上)练习?OwlCarousel2初始化多个实例的最佳方式是什么

你可以使用数据属性来做到这一点。 您的JQuery:

var $carousel = $(this); 

$carousel.owlCarousel({ 
    autoplay : $carousel.data("autoplay"), 
    items : $carousel.data("items"), 
    loop : $carousel.data("loop") 
}); 

你的HTML(使用不同的数据属性):

<div class="owl-carousel" data-autoplay="true"> 
    // Your Owl Items 
</div> 

<div class="owl-carousel" data-items="1" data-loop="true"> 
    // Your Owl Items 
</div>