Carousel
Horizontal carousel built on the native swiper (no hand-written gestures), with autoplay, loop, and self-drawn dots indicator (bottom in-flow / overlay). Page-order math is entirely from @lh-ui/share/core/carousel.
Platform difference (registered): the mini-program runtime cannot enumerate slot children, so page content always goes through data-driven
items+ theitemscoped slot (the web "default slot with multiple children" form does not apply here);showArrowis a desktop-web form and is not rendered on this end.
Basic usage
vue
<template>
<lh-carousel :items="banners" :height="140">
<template #item="{ index, item }">
<view class="page">{{ item }} ({{ index + 1 }})</view>
</template>
</lh-carousel>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const banners = ['Ink wash', 'Color painting', 'Fine brushwork']
</script>Autoplay and non-looping
vue
<template>
<lh-carousel :items="banners" :height="140" :autoplay="3000" :loop="false">
<template #item="{ item }">
<view class="page">{{ item }}</view>
</template>
</lh-carousel>
</template>Controlled v-model
vue
<template>
<lh-carousel v-model="page" :items="banners" :height="140">
<template #item="{ item }">
<view class="page">{{ item }}</view>
</template>
</lh-carousel>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const page = ref(0)
</script>Props
| Prop | Description | Type | Default |
|---|---|---|---|
| v-model / modelValue | Current page index (controlled; uncontrolled when omitted) | number | — |
| items | Page data source (one page per entry, rendered with the item slot) | unknown[] | — |
| autoplay | Autoplay interval ms (0 / omitted = off) | number | 0 |
| loop | Loop wrapping (mapped to swiper's circular) | boolean | true |
| indicator | Indicator form | "dots" | "none" | 'dots' |
| indicatorPosition | Indicator position | "bottom" | "overlay" | 'bottom' |
| height | Height px | number | 200 |
| showArrow | Desktop-web arrows (not rendered on this end, contract placeholder only) | boolean | false |
| disabled | Disabled (greyed, stops autoplay) | boolean | false |
| ariaLabel | Accessible name (falls back to page-count announcement) | string | — |
| customClass | Custom class (root node) | string | — |
| sx | Shorthand layout props | — | — |
Events
| Event | Description | Payload |
|---|---|---|
| update:modelValue | Controlled page write-back | (value: number) |
| change | Page switch (autoplay / touch / programmatic current unified) | (value: number) |
Slots
| Name | Description |
|---|---|
| item | Page content scoped slot { index, item } |
Methods (ref)
| Method | Description |
|---|---|
| prev() / next() | Previous / next page |
| goTo(index) | Jump to a page |
Accessibility
- Root node
role="region"+aria-roledescription="carousel"; accessible name fromariaLabelor the page-count announcement; non-current pagesaria-hidden

