Create custom buttons for slide navigation in Swiper using Vue.js
P粉035600555
P粉035600555 2023-11-02 14:42:51
0
1
735

I need to remove the default navigation (nextEl, prevEl) and make the button with the text "Next Slide Button" scroll to the next slide

<swiper class="news-slider" :sliderd-per-view="1" :modules="[Navigation, Pagination, A11y, Lazy]" navigation="navigation" :navigation="{ nextEl: '.nextArrow'}" :pagination="{ clickable: true, dynamicBullets: true, dynamicMainBullets: 5 }" preload-images="false" lazy="lazy"> 
  <swiperSlide class="swiper-slide" v-for="n in 10" :key="n">
    <div class="news-container"> 
      <div class="news"><img class="news__image swiper-lazy" src="@/assets/img/lookism-transformed-transformed.png" alt=""/>
        <div class="swiper-lazy-preloader"></div>
        <div class="news__info">
          <div class="news__title">title</div>
          <div class="news__description">description</div>
          <div class="news__buttons">
            <button class="normal-button news-button">more</button>
            <button class="next-button"><span class="next-button__text">NEXT SLIDE BUTTON</span><img class="next-button__icon" src="@/assets/img/arrow-right.svg" alt=""/></button>
          </div>
        </div>
      </div>
    </div>
  </swiperSlide>
</swiper>

<script>
  export default {
    components: {
      Swiper,
      SwiperSlide,
    },
    setup() {
      const onSwiper = (swiper) => {
        console.log(swiper);
        
      };
      const onSlideChange = () => {
        console.log('slide change');
      };
      return {
        onSwiper,
        onSlideChange,
        modules: [Navigation, Pagination, Scrollbar, A11y],
      };
    },
  };
</script>

How can I do this? I will be very grateful for your help

P粉035600555
P粉035600555

reply all(1)
P粉294954447

This should do the trick, all you need to do is import useSwiper and assign it to a const variable and then use it inside the div element as swiper.slideNext()

If you don't want to use swiper on your own elements, remove the navigation module.

This is a clearer documentation source

https://swiperjs.com/vue#use-swiper

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template