Carousel カルーセル
横方向カルーセル:ネイティブ swiper のラップ形態(手势を自前で書かない)、 自動再生・ループ折り返し・dots インジケーター(bottom document flow / overlay)自前描画。 ページ順の数式はすべて @lh-ui/share/core/carousel を消費します。
プラットフォーム差異(登録済み):ミニプログラムのランタイムはスロットの 子ノード一覧を取得できないため、ページ内容は常に items データ駆動 + item スコープ付きスロット を使います(web 三端の「デフォルトスロット複数子」 形態はここでは使えません)。
showArrowは web デスクトップ形態のため、 この端では描画しません。
基本的な使い方
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 = ['水墨', '丹青', '工筆']
</script>自動再生と非ループ
vue
<template>
<lh-carousel :items="banners" :height="140" :autoplay="3000" :loop="false">
<template #item="{ item }">
<view class="page">{{ item }}</view>
</template>
</lh-carousel>
</template>制御付き 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
| プロパティ | 説明 | 型 | デフォルト |
|---|---|---|---|
| v-model / modelValue | 現在のページ番号(制御付き。未指定は非制御) | number | — |
| items | ページデータソース(1 項目 = 1 ページ、item スロットと併用) | unknown[] | — |
| autoplay | 自動再生間隔 ms(0 / 未指定 = 無効) | number | 0 |
| loop | ループ折り返し(swiper の circular に対応) | boolean | true |
| indicator | インジケーター形式 | "dots" | "none" | 'dots' |
| indicatorPosition | インジケーター位置 | "bottom" | "overlay" | 'bottom' |
| height | 高さ px | number | 200 |
| showArrow | web デスクトップの矢印(この端では描画しない契約位) | boolean | false |
| disabled | 無効化(灰色化し自動再生を停止) | boolean | false |
| ariaLabel | アクセシブル名称(未指定はページ番号読み上げ) | string | — |
| customClass | カスタムクラス(ルートノード) | string | — |
| sx | sx 簡易レイアウト属性 | — | — |
Events
| イベント | 説明 | コールバック引数 |
|---|---|---|
| update:modelValue | 制御付きページ書き戻し | (value: number) |
| change | ページ切替(autoplay / 指 / プログラム current を一元化) | (value: number) |
Slots
| 名前 | 説明 |
|---|---|
| item | ページ内容のスコープ付きスロット { index, item } |
メソッド(ref)
| メソッド | 説明 |
|---|---|
| prev() / next() | 前のページ / 次のページ |
| goTo(index) | 指定ページへ移動 |
アクセシビリティ
- ルートノードは
role="region"+aria-roledescription="carousel"、 アクセシブル名称はariaLabelまたはページ番号読み上げ。非表示ページはaria-hidden

