# Carousel 轮播
横向轮播:触摸拖拽(位移 / 速度双阈值)、自动轮播(hover 与拖拽期间暂停)、
循环回绕与边界钳制两种模式、dots 指示器(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">页一</div>
<div class="carousel-page">页二</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 | 轮播页内容(每直接子节点一页) |
| item | 具名分页插槽 { index }(与 default 二选一) |
# 方法(ref)
| 方法 | 说明 |
|---|---|
| prev() / next() | 上一页 / 下一页 |
| goTo(index) | 跳转到指定页 |
# 无障碍
- 根元素
role="region"+aria-roledescription="carousel",可达名称取ariaLabel或页码播报文案;方向键 ←/→ 翻页;非当前页aria-hidden
Copyright © 2024-2026 风默文学 | 宁ICP备2024006574号 |
苏公网安备32040002010537