我使用的是Swiper JS (https://swiperjs.com/vue)。每个滑动幻灯片都包含一个按钮。在幻灯片或按钮上单击时,幻灯片将变为活动幻灯片,从而导致滑块移动。
单击非活动幻灯片的按钮时,是否可以防止滑块移动?
我曾尝试将preventClicks
设置为true
,但不幸的是它不起作用。
可以通过单击非活动幻灯片复制到此处(https://swiperjs.com/demos/110-slides-per-view/core.html)。我注意到一些点击并不会移动滑块,而另一些则会。
<swiper :modules="modules"
:scrollbar="{ draggable: true }"
:navigation="{prevEl: '#prev-slide', nextEl: '#next-slide', disabledClass: 'opacity-50 pointer-events-none'}"
:breakpoints="options.breakpoints"
>
<swiper-slide v-for="plan in plans" :key="plan.id">
<plan :plan="plan" @set-plan="setPlan"/>
</swiper-slide>
<div class="flex justify-center mt-2 space-x-2 py-3">
<button type="button"
id="prev-slide"
class="inline-flex items-center px-2.5 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500">
<arrow-narrow-left-icon class="h-5 w-5"/>
</button>
<button type="button"
id="next-slide"
class="inline-flex items-center px-2.5 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500">
<arrow-narrow-right-icon class="h-5 w-5"/>
</button>
</div>
</swiper>
发布于 2021-10-20 02:26:11
可以使用值为button
的prop noSwipingSelector
来实现所需的功能。单击非活动幻灯片的按钮时,它不再滑动到活动幻灯片。
https://stackoverflow.com/questions/69643852
复制相似问题