想在调整浏览器大小的情况下调整页面结构,大于768不用slider,小于等于768就开启slider功能,切换的时候第三次就无法调出效果,网上找到了解决方法
https://github.com/OwlCarousel2/OwlCarousel2/issues/1861
var mission_html = $(".owl-carousel").html();
//
$( window ).resize(function() {
console.log('resizing window '+$( window ).width()) ;
if ($(window).width()<=768){
console.log('enable carousel...');
$('.owl-carousel').trigger('destroy.owl.carousel');
$(".owl-carousel").owlCarousel({
items: 1,
loop: true,
responsiveClass:true,
autoplay: true,
autoplayTimeout:5000,
autoplayHoverPause:true,
dots: true,
autoHeight: false
});
}else{
console.log("resume desktop version")
$(".owl-carousel").html(mission_html);
}
});