Swiper:将自定义幻灯片设置为活动
我正在使用 swiper 显示一年中每个月的滑块。 它从左向右滑动。
我现在想从左侧的本月开始。 如果之前有一个月,则应该在左侧偏移量。
我试图给出.swiper-slide
类活动类.swiper-slide-active
:
<div class="swiper-slide swiper-slide-active">
但这不起作用。
在文档中,我没有发现在设置中设置一个Acive幻灯片的参数。 有什么办法做到这一点吗?
这是我当前的代码: https://codepen.io/cray_io/cray_code/pen/pen/ Dydrlbp
var swiper = new Swiper(".swiper-months", {
cssMode: false,
slidesPerView: 3.5,
spaceBetween: 16,
activeIndex: 6,
mousewheel: {
forceToAxis: true,
},
});
ActiveIndex:6
也无法正常工作。我不确定这是正确的。
I'm using Swiper to show a slider with every month of the year.
It slides from left to right.
I now want to start with the current month on the left side.
If there are month before, they should be in the left offset.
I tried to give the .swiper-slide
class the active class .swiper-slide-active
:
<div class="swiper-slide swiper-slide-active">
But that doesnt work.
In the docs I found no parameter to set a acive slide in the settings.
Is there any way to do this?
Here's my current code: https://codepen.io/cray_code/pen/dydrLBP
var swiper = new Swiper(".swiper-months", {
cssMode: false,
slidesPerView: 3.5,
spaceBetween: 16,
activeIndex: 6,
mousewheel: {
forceToAxis: true,
},
});
The activeIndex: 6
doesn't work either. I'm not sure if that's correct.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
primonslide
,ActiveIndex
仅用于获取实际的活动索引。但是我认为您shoud使用5
6
开始在第六个月开始,因为第一个月以1开始,索引从0开始。Try
initialSlide
,activeIndex
is just for getting the actual active index. But I think you shoud use5
insted of6
to start on sixth month, because first month starts with 1 and indexing starts from 0.