简体   繁体   中英

swiper-button outside container in react

how can I make swiper nav outside the container in react js?

在此处输入图像描述

to

在此处输入图像描述

you can use this

method 1

//add custom btns in some inner comp
 <i className="icon-arrow-long-right review-swiper-button-next"></i>
 <i className="icon-arrow-long-left review-swiper-button-prev"></i>

and next in swiper comp

<Swiper
    navigation={{
      nextEl: '.review-swiper-button-next',
      prevEl: '.review-swiper-button-prev',
    }}
 >
  </Swiper>

or you use this way

method 2

// some-inner-component.jsx
import { React } from 'react';
import { useSwiper } from 'swiper/react';

export default function SlideNextButton() {
  const swiper = useSwiper();

  return (
    <button onClick={() => swiper.slideNext()}>Slide to the next slide</button>
  );
}

more in info : https://swiperjs.com/react#use-swiper

enjoy ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM