0
我使用貓頭鷹旋轉木馬,並有下面的代碼貓頭鷹旋轉木馬時,只有一個圖像
// Home Slider
$("#home-slider").owlCarousel({
loop: true,
items: 1,
dots: false,
nav: true,
autoplayTimeout: 4500,
smartSpeed: 2000,
autoHeight: false,
touchDrag: true,
mouseDrag: true,
margin: 0,
autoplay: true,
slideSpeed: 600,
navText: ['<i class="fa fa-angle-left" aria-hidden="true"></i>', '<i class="fa fa-angle-right" aria-hidden="true"></i>'],
看來工作確定,直到我只有在轉盤中一個幻燈片不顯示。閱讀例如owl carousel 2 not work with loop and 1 items (Bug Fixed Now)故建議用在循環選項
loop: ($(".owl-carousel .owl-item").length >= 1) ? true : false;
然而,當這個代碼運行下面這個結果總是爲假,因此雖然它顯示一個圖像它打破了循環時,有不止一個。我有限的JQuery知識,我已經把一些日誌記錄到控制檯,我認爲正在發生的是循環:($(「。owl-carousel .owl-item」).length> = 1)?真假;在DOM加載之前正在評估代碼,並且找不到正在添加的類。 ($(「。owl-carousel .owl-item」).length> = 1)評估爲True
這個結果是我期望的分析可能是錯誤的,但任何人有什麼建議,我怎麼能得到這個工作?
感謝 保羅
嗨拉爾斯,我閱讀https://github.com/OwlCarousel2/OwlCarousel2/issues/740,它說單個項目不再支持。如果傳送帶中只有一個項目,我也希望使用相同的邏輯來隱藏導航圖標。感謝您的迴應 – Paul
對不起,我必須錯過了棄用 –