# Swiper Used to create carousels, supporting horizontal and vertical sliding, customizable styles and indicator positions, supports video and image resource carousels, and allows setting carousel titles and custom title styles. :::danger Please Note Embedded video is only supported in `h5`, `WeChat Mini Program`, and `DingTalk Mini Program`. Other platforms do not support it, please be aware before using. ::: ## Basic Usage Control whether the carousel automatically plays through the `autoplay` property, initialize the displayed slide with the `v-model:current` property, handle click events by listening to the slide's `click`, and trigger the `change` event after each page carousel ends. ```html ``` ```ts const current = ref(0) const swiperList = ref([ 'https://registry.npmmirror.com/wot-design-uni-assets/*/files/redpanda.jpg', 'https://registry.npmmirror.com/wot-design-uni-assets/*/files/capybara.jpg', 'https://registry.npmmirror.com/wot-design-uni-assets/*/files/panda.jpg', 'https://registry.npmmirror.com/wot-design-uni-assets/*/files/moon.jpg', 'https://registry.npmmirror.com/wot-design-uni-assets/*/files/meng.jpg' ]) function handleClick(e) { console.log(e) } function onChange(e) { console.log(e) } ``` ## Dots Bar Indicator ```html ``` ## Fraction Indicator ```html ``` ## Video Carousel1.3.13 :::danger Please Note Embedded video is only supported in `h5`, `WeChat Mini Program`, and `DingTalk Mini Program`. Other platforms do not support it, please be aware before using. ::: ```html ``` ```ts const videoList = ref([ 'https://unpkg.com/wot-design-uni-assets@1.0.3/VID_115503.mp4', 'https://unpkg.com/wot-design-uni-assets@1.0.3/VID_150752.mp4', 'https://unpkg.com/wot-design-uni-assets@1.0.3/VID_155516.mp4', 'https://registry.npmmirror.com/wot-design-uni-assets/*/files/moon.jpg' ]) ``` ## Manual Video Playback ```html ``` ```ts const videoList = ref([ 'https://unpkg.com/wot-design-uni-assets/VID_115503.mp4', 'https://unpkg.com/wot-design-uni-assets/VID_150752.mp4', 'https://unpkg.com/wot-design-uni-assets/VID_155516.mp4' ]) ``` ## Stop Carousel When Playing Video ```html ``` ```ts const videoList = ref([ 'https://unpkg.com/wot-design-uni-assets/VID_115503.mp4', 'https://unpkg.com/wot-design-uni-assets/VID_150752.mp4', 'https://unpkg.com/wot-design-uni-assets/VID_155516.mp4' ]) ``` ## Manual Switching ```html ``` ## Card Style Set `previousMargin` and `nextMargin` to achieve card carousel style. ```html ``` ```scss .card-swiper { --wot-swiper-radius: 0; --wot-swiper-item-padding: 0 24rpx; --wot-swiper-nav-dot-color: #e7e7e7; --wot-swiper-nav-dot-active-color: #4d80f0; padding-bottom: 24rpx; :deep(.custom-indicator-class) { bottom: -16px; } :deep(.custom-image) { border-radius: 12rpx; } :deep(.custom-image-prev) { height: 168px !important; } } ``` ## Display Multiple Items Set the `display-multiple-items` property to control the number of slides displayed simultaneously. ```html ``` ```scss .card-swiper { --wot-swiper-radius: 0; --wot-swiper-item-padding: 0 24rpx; --wot-swiper-nav-dot-color: #e7e7e7; --wot-swiper-nav-dot-active-color: #4d80f0; padding-bottom: 24rpx; :deep(.custom-indicator-class) { bottom: -16px; } :deep(.custom-image) { border-radius: 12rpx; } :deep(.custom-image-prev) { height: 168px !important; } } ``` ## Attributes | Attribute | Description | Type | Default | Version | |-----------|-------------|------|---------|----------| | list | List of images or videos to display | array | [] | - | | v-model:current | Current slide index | number | 0 | - | | autoplay | Whether to enable auto-play | boolean | false | - | | interval | Auto-play interval (ms) | number | 3000 | - | | duration | Slide animation duration (ms) | number | 500 | - | | indicator | Indicator configuration object | object | { type: 'dots' } | - | | indicator-position | Indicator position | string | 'bottom' | - | | previous-margin | Previous slide margin | string | '0px' | - | | next-margin | Next slide margin | string | '0px' | - | | display-multiple-items | Number of slides to display simultaneously | number | 1 | - | | autoplay-video | Whether to auto-play videos | boolean | true | - | | stop-autoplay-when-video-play | Whether to stop carousel when playing video | boolean | false | - | | loop | Whether to enable loop mode | boolean | true | - | | custom-indicator-class | Custom indicator class | string | - | - | | custom-image-class | Custom image class | string | - | - | | custom-next-image-class | Custom next image class | string | - | - | | custom-prev-image-class | Custom previous image class | string | - | - | ## Events | Event | Description | Parameters | |-------|-------------|------------| | click | Triggered when clicking a slide | event: Event | | change | Triggered when current slide changes | index: number |