I made a slider with a swiper.js in vuejs
everything works fine but the navigation buttons and pagination don’t work
I set the :navigation="true"
and :pagination="{clickable:true, dynamicBullets:true}"
but they still don’t work
where is the problem?
What else should I do?
<template>
<Swiper
class="rounded-xl text-xs w-[95%]"
:modules="[ SwiperEffectCreative]"
:slides-per-view="2"
:space-between="20"
:navigation="true"
:pagination="{clickable:true, dynamicBullets:true}"
:autoplay="{delay: 3000,disableOnInteraction: true,}" >
<SwiperSlide v-for="(product, index) in data" :key='index' class="py-6">
<ProductCard :data="product"/>
</SwiperSlide>
</Swiper>
</template>
2
Answers
I finally managed to fix it
I should have added the
SwiperNavigation
in the modules.I am not an expert on SwiperJS, but according to their docs it seems Navigation and Pagination are modules. This means they need to be both imported into your component logic and included in the "modules" prop. It’s also good practice in Vue to bind your props in the setup function for better code readability. Finally,
EffectCreative
is the correct name of that module (without "Swiper").Or to bind props in your setup method: