Carousel
幻灯片、指示器、箭头、淡入淡出、自动滚动以及通过 Svelte ref 进行控制。
何时使用
轮播在有限的区域内显示多个相同的图像或卡片。重要的操作和信息应保持可用,而无需等待自动更改。选项卡适合显式选择命名部分。
幻灯片和过渡
items 描述带有 children、class/style 以及 width(如果需要)的幻灯片。children 也可以是一个片段或一个内容数组;items 优先。该组件不会将 Svelte 代码片段解析为 React 元素树。
| 问题 | 设置 | 示例 |
|---|---|---|
| 显示序列 | items |
主轮播 |
| 停在边境 | arrows、infinite={false} |
箭头 |
| 改变点的位置 | dotPlacement |
指标 |
| 以外观代替运动 | effect="fade" |
透明度 |
| 启用时移 | autoplay、autoplaySpeed |
自动变更 |
| 从外部按钮转到 | bind:ref、goTo |
方法 |
索引从零开始。 beforeChange 报告转换前的当前索引和下一个索引,afterChange 报告已完成的索引。speed 指定过渡的持续时间(以毫秒为单位)。不要将回调视为幻灯片内容网络下载的确认。
自动滚动和控制
autoplay 包括计时器; dotDuration 对象显示当前指示器的进度。 autoplaySpeed 指定间隔,而不是动画速度。悬停和焦点可以通过 pauseOnHover/pauseOnFocus 暂停移动。在示例中,启动是明确的,因此如果没有用户选择,文档页面不会移动。
提供可访问的停止按钮:仅在悬停时暂停对触摸用户没有帮助。通过 bind:ref: prev(), next(), goTo(index, dontAnimate) 挂载后可以使用外部控制。 slickGoTo 存在于类型中,但不是当前幻灯片的控件。
innerSlider 提供了高级方法和状态,包括 slickPause/slickPlay。responsive 不光滑中缺少它:在调用它之前检查 ref。 RTL保留了原Slick的索引功能;不计算 DOM 克隆的索引。
在垂直模式下,RTL 不镜像翻转方向,也不向包装器添加 RTL 类。当您返回水平查看时,将应用 RTL 样式。
自己的控制和适应性
prevArrow/nextArrow 和 customPaging - 片段。他们接收财产和处理者;将 class/style/onClick 移动到您自己的本机按钮。不可访问的方向没有 onClick。 appendDots 必须保存传递的悬停处理程序。 您的控制 采用这种成分。
slidesToShow 和 slidesToScroll 设置可见和可滚动幻灯片的数量。responsive 包括挂载时的断点规则,因此服务器几何形状可能与客户端不同。不要通过裁剪来隐藏可聚焦元素而不检查它们的可访问性。
ConfigProvider.carousel 设置内部滑块的 class/style,locale.carousel — 箭头标签。外部节点可通过 bind:nativeElement 访问。轮播设计令牌(design tokens)控制箭头和指示器;语义 classNames/styles 不会添加到单独的公共 API 中。
prefixCls 指定 Carousel 外部包装器的完整本地前缀、其 RTL/vertical 类和进度动画名称。空字符串和 undefined 使用带有 -carousel 后缀的 ConfigProvider.prefixCls。 Slick 类保持不变:本地前缀不会重命名轨道、幻灯片、箭头或 dots。 轮播前缀 显示独立区域、公共 ref、保存幻灯片、草稿和焦点。切换前缀本身不会触发幻灯片更改事件。
嵌套单选/复选框 CSS 选择器遵循与本地 Carousel.prefixCls 分开的公共提供者前缀。这并不声明 Radio 和 Checkbox 前缀本身的迁移已完成。命名空间 theme.cssVar.prefix 的设置独立于轮播 CSS 类。
示例
基本轮播
四张幻灯片和指示器; afterChange 报告已完成的转换。
<script lang="ts">
import { Carousel, type CarouselItem } from '@woodger/antd';
const items = [1, 2, 3, 4].map(number => ({ children: String(number), class: 'gallery-slide' }));
let current = $state(0);
const slides: readonly CarouselItem[] = items;
</script>
<style>
.preview { min-width:0; }
.preview :global(.gallery-slide) {
height:160px;
line-height:160px;
text-align:center;
background:#364d79;
color:#fff;
font-size:28px;
font-weight:600;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div
class="preview"
role="region"
aria-label={("基本轮播")}
><Carousel
items={(slides)}
afterChange={index => { current = index; }}
/></div>
<output aria-label={("基本幻灯片")}>{("滑动 ")}{(current + 1)}{(" 满分 4")}</output>
箭头和边框
关闭 infinite 时,它会停止第一张和最后一张幻灯片上的过渡。
<script lang="ts">
import { Carousel, Checkbox } from '@woodger/antd';
const items = [1, 2, 3, 4].map(number => ({ children: String(number), class: 'gallery-slide' }));
let infinite = $state(false);
let current = $state(0);
</script>
<style>
.preview { min-width:0; }
.preview :global(.gallery-slide) {
height:160px;
line-height:160px;
text-align:center;
background:#364d79;
color:#fff;
font-size:28px;
font-weight:600;
}
.controls {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div
class="controls"
><Checkbox
bind:checked={infinite}
>{("循环旋转木马")}</Checkbox></div>
<div
class="preview"
role="region"
aria-label={("带箭头的旋转木马")}
><Carousel
items={(items)}
arrows
{infinite}
afterChange={index => { current = index; }}
/></div>
<output aria-label={("用箭头滑动")}>{("滑动 ")}{(current + 1)}{(" 满分 4")}</output>
指示器位置
top、bottom、start 和 end;侧面指示器将转盘切换为垂直模式。
<script lang="ts">
import { Carousel, Select, type DotPlacement } from '@woodger/antd';
const items = [1, 2, 3, 4].map(number => ({ children: String(number), class: 'gallery-slide' }));
let dotPlacement = $state<DotPlacement>('bottom');
</script>
<style>
.preview { min-width:0; }
.preview :global(.gallery-slide) {
height:160px;
line-height:160px;
text-align:center;
background:#364d79;
color:#fff;
font-size:28px;
font-weight:600;
}
.controls {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
}
</style>
<div
class="controls"
><Select
aria-label={("指示器位置")}
bind:value={dotPlacement}
options={([
{ value: 'top', label: "多于" }, { value: 'bottom', label: "从下面" },
{ value: 'start', label: "一开始" }, { value: 'end', label: "在最后" }
])}
/></div>
<div class="preview"><Carousel items={(items)} {dotPlacement} arrows /></div>
自动滚动
打开自动滚动。指向或聚焦可使其暂停;该开关允许您明确停止。
<script lang="ts">
import { Carousel, Checkbox } from '@woodger/antd';
const items = [1, 2, 3, 4].map(number => ({ children: String(number), class: 'gallery-slide' }));
let playing = $state(false);
let current = $state(0);
</script>
<style>
.preview { min-width:0; }
.preview :global(.gallery-slide) {
height:160px;
line-height:160px;
text-align:center;
background:#364d79;
color:#fff;
font-size:28px;
font-weight:600;
}
.controls {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div
class="controls"
><Checkbox
bind:checked={playing}
>{("自动更换幻灯片")}</Checkbox></div>
<div
class="preview"
><Carousel
items={(items)}
autoplay={playing}
autoplaySpeed={2000}
speed={300}
pauseOnHover
pauseOnFocus
afterChange={index => { current = index; }}
/></div>
<output aria-label={("自动滑轨")}>{("滑动 ")}{(current + 1)}{(" 满分 4")}</output>
顺利出苗
effect="fade" 用透明度的变化代替水平移动。
<script lang="ts">
import { Carousel, type CarouselRef } from '@woodger/antd';
const items = [1, 2, 3, 4].map(number => ({ children: String(number), class: 'gallery-slide' }));
let current = $state(0);
let ref = $state<CarouselRef>();
</script>
<style>
.preview { min-width:0; }
.preview :global(.gallery-slide) {
height:160px;
line-height:160px;
text-align:center;
background:#364d79;
color:#fff;
font-size:28px;
font-weight:600;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div
class="preview"
><Carousel
items={(items)}
effect="fade"
arrows
bind:ref
afterChange={index => { current = index; }}
/></div>
<output aria-label={("外观幻灯片")}>{("滑动 ")}{(current + 1)}{(" 满分 4")}</output>
指标进展情况
autoplay.dotDuration 显示当前幻灯片的持续时间。通过开关启动。
<script lang="ts">
import { Carousel, Checkbox } from '@woodger/antd';
const items = [1, 2, 3, 4].map(number => ({ children: String(number), class: 'gallery-slide' }));
let playing = $state(false);
</script>
<style>
.preview { min-width:0; }
.preview :global(.gallery-slide) {
height:160px;
line-height:160px;
text-align:center;
background:#364d79;
color:#fff;
font-size:28px;
font-weight:600;
}
.controls {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
}
</style>
<div class="controls">
<Checkbox bind:checked={playing}>
{("显示自动进度")}
</Checkbox>
</div>
<div class="preview"><Carousel items={(items)} autoplay={playing ? {
dotDuration: true
} : false} autoplaySpeed={3000} /></div>
方法和事件
bind:ref 提供 prev、next 和 goTo;索引是从头开始计算的。
<script lang="ts">
import { Carousel, Button, type CarouselRef } from '@woodger/antd';
const items = [1, 2, 3, 4].map(number => ({ children: String(number), class: 'gallery-slide' }));
let ref = $state<CarouselRef>();
let current = $state(0);
let transition = $state('—');
</script>
<style>
.preview { min-width:0; }
.preview :global(.gallery-slide) {
height:160px;
line-height:160px;
text-align:center;
background:#364d79;
color:#fff;
font-size:28px;
font-weight:600;
}
.controls {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div class="controls">
<Button onclick={() => ref?.prev()}>{("后退")}</Button><Button onclick={() => ref
?.next()}>{("向前")}</Button>
<Button onclick={() => ref?.goTo(2, true)}>{("到第三张幻灯片")}</Button>
</div>
<div class="preview"><Carousel items={(items)} bind:ref beforeChange={(
from,
to
) => { transition = ("" + String((from)) + " → " + String((to)) + ""); }} afterChange={index => {
current = index;
}} /></div>
<output aria-label={("轮播事件")}>{("滑动 ")}{(current + 1)}{("。过渡: ")}{transition}.</output>
自己的双手和指标
代码片段显式地将 class、style 和处理程序应用于本机按钮。
<script lang="ts">
import { Carousel, type CarouselArrowProps } from '@woodger/antd';
const items = [1, 2, 3, 4].map(number => ({ children: String(number), class: 'gallery-slide' }));
let current = $state(0);
</script>
<style>
.preview { min-width:0; }
.preview :global(.gallery-slide) {
height:160px;
line-height:160px;
text-align:center;
background:#364d79;
color:#fff;
font-size:28px;
font-weight:600;
}
output {
display: block;
margin-top: 16px;
}
</style>
{#snippet previous(props: CarouselArrowProps)}<button type="button" class={props.class} style={props
.style} onclick={props.onClick} disabled={!props
.onClick} aria-label={("靠卡回来")}></button>{/snippet}
{#snippet next(props: CarouselArrowProps)}<button type="button" class={props.class} style={props
.style} onclick={props.onClick} disabled={!props
.onClick} aria-label={("继续打卡")}></button>{/snippet}
{#snippet paging(index: number, props: { onClick: (event: MouseEvent) => void })}<button
type="button"
onclick={props.onClick}
aria-label={("打开幻灯片 " + String((index + 1)) + "")}
>{(index + 1)}</button>{/snippet}
<div
class="preview"
><Carousel
items={(items)}
arrows
prevArrow={previous}
nextArrow={next}
customPaging={paging}
afterChange={index => { current = index; }}
/></div>
<output
aria-label={("带有自定义按钮的滑动")}
>{("滑动 ")}{(current + 1)}{(" 满分 4")}</output>
几张幻灯片
宽屏幕上的三张幻灯片;显示的最大尺寸为 768 px。responsive 规则在挂载时连接。
<script lang="ts">
import { Carousel, type CarouselResponsiveObject } from '@woodger/antd';
const items = [1, 2, 3, 4].map(number => ({ children: String(number), class: 'gallery-slide' }));
const responsive: readonly CarouselResponsiveObject[] = [{
breakpoint: 768, settings: {
slidesToShow: 1
}
}];
</script>
<style>
.preview { min-width:0; }
.preview :global(.gallery-slide) {
height:160px;
line-height:160px;
text-align:center;
background:#364d79;
color:#fff;
font-size:28px;
font-weight:600;
}
</style>
<div
class="preview"
><Carousel
id="carousel-responsive"
items={(items)}
{responsive}
slidesToShow={3}
infinite={false}
arrows
/></div>
RTL 和常规设置
ConfigProvider 设置内部滑块的方向、箭头标签和设计。
<script lang="ts">
import { Carousel, ConfigProvider } from '@woodger/antd';
const items = [1, 2, 3, 4].map(number => ({ children: String(number), class: 'gallery-slide' }));
</script>
<style>
.preview { min-width:0; }
.preview :global(.gallery-slide) {
height:160px;
line-height:160px;
text-align:center;
background:#364d79;
color:#fff;
font-size:28px;
font-weight:600;
}
</style>
<ConfigProvider
direction="rtl"
carousel={{ style: `
border-radius: 8px;
overflow: hidden;
` }}
locale={({ carousel: { prevSlide: "上一帧", nextSlide: "下一帧" } })}
>
<div class="preview"><Carousel items={(items)} arrows /></div>
</ConfigProvider>
两个作用域都使用相同的本地类。前缀更改指标的外部包装和动画; Slick 及其子组件的类被保留。
在垂直模式下,RTL 不镜像翻转。 RTL 类用于水平查看。
轮播和进度前缀
通用和局部 prefixCls、RTL 和垂直指示器。更改前缀时会保留当前幻灯片和草稿;自动滚动是显式触发的。
<script lang="ts">
import { Button, Carousel, Checkbox, ConfigProvider, Input, type CarouselRef } from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
let vertical = $state(false);
let rtl = $state(false);
let playing = $state(false);
let draft = $state('');
let ref = $state<CarouselRef>();
let current = $state(0);
let changes = $state(0);
let transition = $state('—');
const prefix = $derived(custom ? 'suite' : 'ant');
</script>
<style>
.example {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 20px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.preview { min-width: 0; }
.slide {
display: grid;
box-sizing: border-box;
height: 160px;
align-content: center;
justify-items: center;
padding: 24px;
background: #364d79;
color: #fff;
}
label {
display: grid;
gap: 8px;
width: 100%;
max-width: 220px;
min-width: 0;
}
.preview :global(.prefix-neighbor-slide) {
box-sizing: border-box;
height: 100px;
padding: 32px;
background: #364d79;
color: #fff;
text-align: center;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
</style>
{#snippet cover()}<div class="slide">{("开始观看")}</div>{/snippet}
{#snippet details()}<div class="slide">{("项目描述")}</div>{/snippet}
{#snippet editor()}
<div class="slide">
<label>{("草稿幻灯片\n ")}<Input bind:value={draft} aria-label={("带前缀的轮播草稿")} style="width:100%" />
</label>
</div>
{/snippet}
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("通用前缀轮播套件")}</Checkbox>
<Checkbox bind:checked={local}>{("轮播本地前缀")}</Checkbox>
<Checkbox
bind:checked={vertical}
>{("带前缀的垂直轮播")}</Checkbox>
<Checkbox bind:checked={rtl}>{("带前缀的 RTL 轮播")}</Checkbox>
<Checkbox
bind:checked={playing}
>{("带前缀的自动滚动轮播")}</Checkbox>
</div>
<div>
<Button
disabled={!ref}
onclick={() => ref?.goTo(2, true)}
>{("转到幻灯片草稿")}</Button>
</div>
<ConfigProvider prefixCls={prefix} direction={rtl ? 'rtl' : 'ltr'}
theme={{ cssVar: { prefix: 'carousel-theme' } }}>
<section class="preview" aria-label={("带前缀的主轮播")}>
<Carousel
bind:ref
prefixCls={local ? 'project-carousel' : ''}
rootClassName="prefix-carousel-main"
speed={0}
arrows
dotPlacement={vertical ? 'start' : 'bottom'}
autoplay={playing ? { dotDuration: true } : false}
autoplaySpeed={5000}
items={([{ children: cover }, { children: details }, { children: editor }])}
beforeChange={(from, to) => { transition = ("" + String((from)) + " → " + String((to)) + ""); }}
afterChange={index => {
current = index;
changes += 1;
}}
/>
</section>
</ConfigProvider>
<ConfigProvider prefixCls="neighbor">
<section class="preview" aria-label={("带前缀的相邻轮播")}>
<Carousel prefixCls={local ? 'project-carousel' : ''} rootClassName="prefix-carousel-neighbor"
speed={0} arrows items={([
{ children: "邻近地区", class: 'prefix-neighbor-slide' },
{ children: "独立观看", class: 'prefix-neighbor-slide' }
])} />
</section>
</ConfigProvider>
<output
aria-label={("带前缀的轮播幻灯片")}
>{("\n 滑动 ")}{(current + 1)}{(" 从 3 开始;过渡: ")}{changes}{(";最后的: ")}{transition}
</output>
<output
aria-label={("轮播前缀")}
>{("\n 一般的: ")}{prefix}{(";班级: ")}{(local ? 'project-carousel' : prefix + '-carousel')}
</output>
<p>
{("两个作用域都使用相同的本地类。前缀更改指标的外部包装和动画; Slick 及其子组件的类被保留。")}
</p>
<p>
{("在垂直模式下,RTL 不镜像翻转。 RTL 类用于水平查看。")}
</p>
</div>
引导视图
保存的评论示例:外部按钮、自动滚动、淡入淡出和当前索引。
<script lang="ts">
import { Button, Carousel, type CarouselRef } from '@woodger/antd';
let ref = $state<CarouselRef>();
let current = $state(0);
let autoplay = $state(false);
let fade = $state(false);
</script>
<style>
.example {
max-width: 720px;
min-width: 0;
}
.controls {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
}
.controls label {
display: flex;
align-items: center;
gap: 8px;
}
.slide {
display: grid;
height: 160px;
place-items: center;
background: #364d79;
color: #fff;
font-size: 32px;
font-weight: 600;
}
output {
display: block;
margin-top: 16px;
}
</style>
{#snippet first()}<div class="slide">1</div>{/snippet}
{#snippet second()}<div class="slide">2</div>{/snippet}
{#snippet third()}<div class="slide">3</div>{/snippet}
{#snippet fourth()}<div class="slide">4</div>{/snippet}
<div class="example">
<div class="controls" role="group" aria-label={("轮播管理")}>
<Button onclick={() => ref?.prev()}>{("上一张幻灯片")}</Button>
<Button onclick={() => ref?.next()}>{("下一张幻灯片")}</Button>
<label><input
type="checkbox"
bind:checked={autoplay}
/>{(" 自动滚动")}</label>
<label><input
type="checkbox"
bind:checked={fade}
/>{(" 顺利出苗")}</label>
</div>
<Carousel
bind:ref
items={([{ children: first }, { children: second }, { children: third }, {
children: fourth
}])}
{autoplay}
effect={fade ? 'fade' : 'scrollx'}
arrows
afterChange={index => { current = index; }}
/>
<output aria-label={("当前幻灯片")}>{("滑动 ")}{(current + 1)}{(" 满分 4")}</output>
</div>
API
这些示例是根据当前的 ant.design 页面和已安装包的公共 API 进行检查的。 Props 的完整定义位于 @woodger/antd 中。
| 主题 | 示例或限制 |
|---|---|
| Basic | 四张幻灯片和一个变更事件。 |
| Position | 四个位置都可以。 |
| Scroll automatically | 受控启动、hover/focus 暂停。 |
| Fade in | 透明过渡。 |
| Arrows for switching | 箭头和有限列表。 |
| Progress of dots | 使用 dotDuration autoplay。 |
| CSS prefix | 本地包装器和进度、公共 prefix 和独立邻居;保存当前幻灯片和编辑器。 |
| 属性 | 描述 | 类型 | 默认 |
|---|---|---|---|
prefixCls | 包装器、RTL/vertical 状态和进度动画的完整本地前缀。空字符串和 undefined 使用提供者前缀;光滑的类被保留。 | string | ConfigProvider.prefixCls + "-carousel" |
items | 幻灯片阵列;优先于 children。 | readonly CarouselItem[] | — |
children | 值、片段或数组;明确的 items 是更好的选择。 | CarouselContent | — |
arrows | 过渡箭头。 | boolean | false |
dots | 当前幻灯片的指示器。 | boolean | { class?, className? } | true |
dotPlacement | 指示器的位置;start/end 启用垂直模式。 | top | bottom | start | end | bottom |
effect | 运动或透明度。 | scrollx | fade | scrollx |
autoplay | 自动滚动和进度指示器。 | boolean | { dotDuration?: boolean } | false |
autoplaySpeed | 自动滚动间隔(以毫秒为单位); Slick 增加了 50 毫秒。 | number | 3000 |
speed | 转换的持续时间和 afterChange 计时器。 | number | 500 |
infinite | 绕圈重复幻灯片。 | boolean | true |
beforeChange | 转换前的索引。 | (from, to) => void | — |
afterChange | 转换完成后的索引。 | (index) => void | — |
responsive | 视口宽度的灵活设置。 | readonly CarouselResponsiveObject[] | — |
customPaging | 自带指示按钮。 | Snippet<[index, props]> | — |
prevArrow | 拥有上一个箭头。 | Snippet<[CarouselArrowProps]> | — |
nextArrow | 拥有下一个箭头。 | Snippet<[CarouselArrowProps]> | — |
ref | 挂载后使用控制方法 bind:ref。 | CarouselRef | — |
方法
ref.goTo(index, dontAnimate?), ref.next(), ref.prev() 管理转换。 ref.nativeElement - 外层 div; innerSlider 提供委托的 Slick API。公共 CarouselSlickSettings 中提供了其他设置;此处不再重复完整的合同。
Semantic DOM
外部 div 包含内部滑块、视口、轨道、幻灯片、箭头和指示器。命名 classNames/styles 没有插槽。对于内部滑块,可以使用 class/style 和 ConfigProvider.carousel ; rootClassName 指的是外部 div。
prefixCls 更改外部包装器、其 RTL/vertical 状态和 duration 关键帧名称。 slick-slider、slick-track、slick-slide 和controls 类被保留。嵌套单选/复选框选择器使用通用提供程序前缀,无论主题的本地 Carousel.prefixCls 和命名空间如何。
将旋转木马包裹在指定区域中。箭头按钮具有来自 locale.carousel 的标签;您需要自己命名自己的按钮。隐藏的幻灯片内容被 aria-hidden;交互式幻灯片元素需要单独的 Tab 顺序检查。对于自动滚动,请保留明确的停止控制。
注册令牌
theme.components.Carousel 应用七个组件标记:箭头大小和缩进、指示器的几何形状和位置。 class/style 和 ConfigProvider.carousel 可用于本地样式。
| 代币 | 目的 |
|---|---|
arrowOffset | 箭头相对于边缘的偏移量。 |
arrowSize | 箭头大小。 |
dotActiveWidth | 活动指示器的宽度。 |
dotGap | 指标之间的间隔。 |
dotHeight | 指示器高度。 |
dotOffset | 指示器距边缘的距离。 |
dotWidth | 常规指示器的宽度。 |
| 代币 | 当前值 |
|---|---|
colorBgContainer | #ffffff |
colorText | rgba(0,0,0,0.88) |
borderRadius | 6 |
motionDurationSlow | 0.3s |
FAQ
如何移动到所需的幻灯片?
挂载后,调用 ref.goTo(index, dontAnimate)。上一个/下一个可供邻居使用;索引从零开始。
为什么 slickGoTo 属性没有切换幻灯片?
它存储在上游类型中,但通过 ref 的 goTo 方法旨在进行控制。
如何添加自己的箭头?
传递片段 prevArrow/nextArrow 并将生成的处理程序和样式应用到本机按钮。
为什么自动滚动停止了?
检查 pauseOnHover/pauseOnFocus 和 autoplay 状态。为了便于控制,请为用户留下明确的暂停按钮。