# Carousel カルーセル

横方向カルーセル:タッチドラッグ(移動量 / 速度の 2 つの閾値)、自動再生(hover とドラッグ中は一時停止)、 ループ巻き戻しと境界クランプの 2 つのモード、ドットインジケーター(bottom / overlay)とデスクトップ向け矢印を備えます。 ページ番号の計算はすべて @lh-ui/share/core/carousel を利用しています。

カルーセル
<template>
  <div class="demo-col" style="gap: 18px">
    <div class="demo-row" style="max-width: 420px">
      <LhCarousel :autoplay="3000" :height="160">
        <div class="carousel-page">水墨</div>
        <div class="carousel-page">丹青</div>
        <div class="carousel-page">工笔</div>
      </LhCarousel>
    </div>
    <div class="demo-row" style="max-width: 420px">
      <LhCarousel v-model="page" :loop="false" :autoplay="0" show-arrow :height="140">
        <div class="carousel-page">ページ 1</div>
        <div class="carousel-page">ページ 2</div>
      </LhCarousel>
    </div>
    <p class="demo-note">非ループの制御された現在ページ:{{ page }}(方向キー ←/→ でもページ送りできます)</p>
  </div>
</template>

<script>
export default {
  data: () => ({
    page: 0,
  }),
}
</script>

# Props

プロパティ 説明 型 デフォルト値
v-model / modelValue 現在のページ番号(制御。指定しない場合は非制御で自動動作) number —
autoplay 自動再生の間隔 ms(0 / 指定なし = 自動再生しない) number 0
loop ループ巻き戻し boolean true
indicator インジケーターの形態 'dots' \| 'none' 'dots'
indicatorPosition インジケーターの位置 'bottom' \| 'overlay' 'bottom'
height 高さ px number 200
showArrow 左右の矢印を表示(デスクトップ端) boolean false
disabled 無効 boolean false
ariaLabel アクセシビリティ名(未指定時はページ番号の読み上げ) string —
sx sx の簡易レイアウト — —

# Events

イベント 説明 コールバックパラメータ
input v-model 双方向バインディングイベント(制御されたページ番号の書き戻し) (value: number)
change ページの切り替え (value: number)

# Slots

スロット 説明
default カルーセルページの内容(直接の子ノードごとに 1 ページ)
item 名前付きページ分割スロット { index }(default とは排他)

# メソッド(ref)

メソッド 説明
prev() / next() 前のページ / 次のページ
goTo(index) 指定ページへジャンプ

# アクセシビリティ

  • ルート要素に role="region" + aria-roledescription="carousel"、アクセシブル名は ariaLabel またはページ番号の読み上げテキスト。方向キー ←/→ でページ送り。非現在ページは aria-hidden
最終更新: 2026/12/4 0:49:57

Copyright © 2024-2026 FengMo WenXue