如何让 owl-carousel 自动播放?
How to make owl-carousel autoplay?
然后我想让我的 owl-carousel 自动播放
我从 Whosebug 中的一些帖子中获取它,但它不起作用
.js -->
$(document).ready(function(){
owl = $(".owl-carousel");
owl.owlCarousel({
loop:true,
autoplaySpeed:1000,
items:5,
autoplay:true
});
});
我的html-->
<div class="container awards mt-5">
<h1 class="text-title text-red">
Awards
</h1>
<div class="owl-carousel owl-six" data-inner-pagination="true" data-white-pagination="true" data-nav="false" data-autoPlay="true">
{% for item in page.awards.all %}
{% image item.image width-2048 as event_image %}
<div class="award-image" style="background-image:url({{ event_image.url }})"></div>
{% endfor %}
</div>
</div>
autoplay:true
的值将使滑块自动播放。
编辑您的滑块文件并向其添加 autoplay:true
而不是粘贴整个代码段。
如果您在参数末尾添加 autoplay:true
作为最后一个参数,则不需要逗号 ,
。但是,如果你在中间添加它,那么你将需要一个逗号,如下所示:autoplay:true,
此外,如果你想让滑块每5秒自动旋转一次,那么将true的值替换为5000。示例:autoplay:5000
然后我想让我的 owl-carousel 自动播放 我从 Whosebug 中的一些帖子中获取它,但它不起作用
.js -->
$(document).ready(function(){
owl = $(".owl-carousel");
owl.owlCarousel({
loop:true,
autoplaySpeed:1000,
items:5,
autoplay:true
});
});
我的html-->
<div class="container awards mt-5">
<h1 class="text-title text-red">
Awards
</h1>
<div class="owl-carousel owl-six" data-inner-pagination="true" data-white-pagination="true" data-nav="false" data-autoPlay="true">
{% for item in page.awards.all %}
{% image item.image width-2048 as event_image %}
<div class="award-image" style="background-image:url({{ event_image.url }})"></div>
{% endfor %}
</div>
</div>
autoplay:true
的值将使滑块自动播放。
编辑您的滑块文件并向其添加 autoplay:true
而不是粘贴整个代码段。
如果您在参数末尾添加 autoplay:true
作为最后一个参数,则不需要逗号 ,
。但是,如果你在中间添加它,那么你将需要一个逗号,如下所示:autoplay:true,
此外,如果你想让滑块每5秒自动旋转一次,那么将true的值替换为5000。示例:autoplay:5000