본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Swiper

원문 보기 위키 갱신

Swiper (스와이프)

사진이나 카드를 한 줄로 넘겨 보여줄 때 쓰는 컴포넌트예요. 배너 슬라이드 같은 그룹 회전에 자주 사용돼요.

출처: 문서

본문

소개

사진이나 카드 그룹을 회전시킬 때 자주 사용해요.

설치

import { createApp } from 'vue'
import { Swiper, SwiperItem } from '@nutui/nutui'

const app = createApp()
app.use(Swiper)
app.use(SwiperItem)

기본 사용법

auto-play 자동 회전 지속 시간 init-page 초기 인덱스 값 pagination-visible 페이징 인디케이터 표시 pagination-color 인디케이터 색 커스텀

demo: swiper basic

비동기 로딩

demo: swiper async

동적 로딩

그림을 동적으로 추가/삭제하는 걸 지원해요

demo: swiper dynamic

커스텀 너비

demo: swiper width

Page Slot

demo: swiper page

Ref 메서드

demo: swiper methods

세로 방향

demo: swiper vertical

API

Props

Attribute 설명 Type 기본값
width 회전 카드의 너비 number | string -
height 회전 카드의 높이 number | string -
direction 회전 방향, 값: horizontal, vertical string 'horizontal'
pagination-visible 페이징 인디케이터를 표시할지 여부 boolean false
pagination-color 페이징 인디케이터가 선택된 색 string '#fff'
pagination-unselected-color 페이징 인디케이터가 선택되지 않은 색 string '#ddd'
loop 회전(loop) 여부 boolean true
duration 애니메이션 지속 시간(단위 ms) number | string 500
auto-play 자동 회전 지속 시간, 0이면 자동 회전 없음 number | string 0
init-page 초기 인덱스 값 number | string 0
touchable 터치로 슬라이드할 수 있는지 여부 boolean true
is-prevent-default 슬라이딩 중 기본 이벤트를 막을지 여부 boolean true
is-stop-propagation 슬라이딩 중 버블링을 막을지 여부 boolean true

Events

Event 설명 인자
change 슬라이딩 후 콜백 현재 인덱스 값

Slots

이름 설명
page 인디케이터 커스텀

Methods

Event 설명 인자
prev 이전 페이지로 전환해요 -
next 다음 페이지로 전환해요 -
to 지정한 회전으로 전환해요 index:number

테마 (Theming)

CSS Variables

컴포넌트는 스타일을 커스터마이즈할 수 있는 CSS 변수를 제공해요. ConfigProvider 컴포넌트를 참고하세요.

이름 기본값
--nut-swiper-pagination-item-width 8px
--nut-swiper-pagination-item-height 3px
--nut-swiper-pagination-item-margin-right 7px
--nut-swiper-pagination-item-border-radius 2px

더 알아보기 (Learn more)