SvelteKit and Swiper 8.4.2 : how to make clickable Slide

Viewed 5

I'm trying make my slides clickable using swiper with svelte

<Swiper
  lazy={true}
  on:swiper={onSwiper}
  on:slideChange={() => console.log('slide change')}
  on:progress={onProgress}
 ...
>
<SwiperSlide> <img on:click={doSmt} id='1' src="/src/lib/img/img_1.svg" alt=""/>  </SwiperSlide>
<SwiperSlide> <img on:click={doSmt} id='2' src="/src/lib/img/img_2.svg" alt=""/> </SwiperSlide>
...
</Swiper>

but only the first slide works : can somebody tell me why is that ? Tx

1 Answers

OK, I just found that the method should be used inside the elem like so :

<Swiper
on:click={(e) => console.log('clicked el : ' +  e)}
>

If someone ever struggle to find it in the doc like me...

Related