Carousel
여러 장의 콘텐츠를 슬라이드로 넘겨 보여주는 컴포넌트예요. 자동 재생, 드래그 전환, 여러 장씩 보기 같은 옵션을 조합해서 배너나 갤러리를 쉽게 만들 수 있어요. 화살표와 도트를 커스텀 렌더링하는 것도 가능하죠.
출처: 문서
본문
보통 좋은 소식을 보여줄 때 사용해요.
Demos
basic.vue
arrow.vue
autoplay.vue
dots.vue
vertical.vue
space-between.vue
slides-per-view.vue
slides-per-view-auto.vue
centered.vue
effect.vue
transition-name.vue
hover.vue
keyboard.vue
mousewheel.vue
simulate-drag.vue
custom-arrow-and-dots.vue
custom-card.vue
custom-dots.vue
API
Carousel Props
| 이름 | 타입 | 기본값 | 설명 | 버전 |
|---|---|---|---|---|
| autoplay | boolean |
false |
자동으로 넘어갈지 여부. | |
| centered-slides | boolean |
false |
현재 보고 있는 캐러셀을 가운데에 둘지 여부. | 2.24.0 |
| current-index | number |
undefined |
현재 인덱스. | 2.24.0 |
| default-index | number |
0 |
기본 인덱스. | 2.24.0 |
| direction | 'horizontal' | 'vertical' |
'horizontal' |
캐러셀이 보여지는 방향. | |
| dot-placement | 'top' | 'bottom' | 'left' | 'right' |
'bottom' |
패널 안에서 도트의 위치. | 2.24.0 |
| dot-type | 'dot' | 'line' |
'dot' |
도트 스타일. | 2.24.0 |
| draggable | boolean |
false |
마우스로 드래그해서 캐러셀을 넘길지 여부. | 2.24.0 |
| effect | 'slide' | 'fade' | 'card' | 'custom' |
'slide' |
캐러셀 전환 시 전환 효과. | 2.24.0, 'card' 2.24.2 |
| interval | number |
5000 |
자동 재생 간격 (ms). | |
| keyboard | boolean |
false |
키 입력으로 캐러셀을 넘길지 여부. 포커스가 Dots에 있을 때만 동작해요. | 2.24.0 |
| loop | boolean |
true |
반복할지 여부. | 2.24.0 |
| mousewheel | boolean |
false |
마우스 휠로 캐러셀을 넘길지 여부. | 2.24.0 |
| next-slide-style | object | string |
undefined |
다음 슬라이드의 style. | 2.27.0 |
| prev-slide-style | object | string |
undefined |
이전 슬라이드의 style. | 2.27.0 |
| show-arrow | boolean |
false |
화살표 버튼을 표시할지 여부. | 2.24.0 |
| show-dots | boolean |
true |
도트를 표시할지 여부. | 2.24.0 |
| slides-per-view | 'auto' | number |
1 |
화면 하나에 표시할 캐러셀 수. | 2.24.0 |
| space-between | number |
0 |
캐러셀 사이의 간격. | 2.24.0 |
| touchable | boolean |
true |
터치로 캐러셀을 넘길지 여부. | 2.24.0 |
| transition-style | { transitionDuration?: string, transitionTimingFunction?: string } |
{ transitionDuration: '300ms' } |
전환 효과의 style. | 2.24.0 |
| transition-props | TransitionProps |
undefined |
커스텀 전환 효과 속성, reference. | 2.24.0 |
| trigger | 'click' | 'hover' |
'click' |
수동 전환 방식. | |
| on-update:current-index | (currentIndex: number, lastIndex: number) => void |
undefined |
현재 인덱스가 바뀔 때 호출되는 콜백 함수. | 2.24.0 |
Carousel Slots
| 이름 | 매개변수 | 설명 | 버전 |
|---|---|---|---|
| default | () |
캐러셀 콘텐츠. | |
| arrow | (info: { total: number, currentIndex: number, to: (index: number) => void, prev: () => void, next: () => void }) |
화살표. | 2.24.0 |
| dots | (info: { total: number, currentIndex: number, to: (index: number) => void }) |
도트. | 2.24.0 |
Carousel Methods
| 이름 | 타입 | 설명 | 버전 |
|---|---|---|---|
| to | (index: number) => void |
해당 인덱스로 슬라이드해요. | 2.24.0 |
| prev | () => void |
이전 페이지로 슬라이드해요. | 2.24.0 |
| next | () => void |
다음 페이지로 슬라이드해요. | 2.24.0 |
| getCurrentIndex | () => number |
현재 인덱스를 가져와요. | 2.24.0 |
더 알아보기 (Learn more)
전환 효과를 바꾸고 싶다면 effect와 transition-props 항목을 참고하세요. 화살표와 도트를 완전히 새로 디자인하는 방법은 custom-arrow-and-dots, custom-dots 데모에 정리돼 있어요.