展示类 · ScrollList
滚动列表
滚动列表。
Vue 使用说明:从
@aifuxi/semi-ui-vue/scroll-list子路径引入组件,浏览器构建会自动按需加载默认主题。本页 Vue API 与示例以当前公开实现为准。
代码演示
如何引入
查看代码 · js
基本使用
滚动列表提供了一个类似于 iOS 操作系统的滚动选择模式,同时支持滚动至指定窗口位置选择与点击选择。
无限滚动列表
- 上午
- 下午
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
API 参考
Vue 契约
以下内容以
packages/ui/src/scroll-list/types.ts、packages/ui/src/scroll-list/index.ts的公开类型为准。
Vue 用法
ScrollItem同时作为ScrollList.Item静态成员和具名导出提供。ScrollList的 header、footer 同时支持 VNode prop 和同名插槽,插槽优先。ScrollItem.transform与ItemData.transform是显示值转换 callback props;ItemData 中的配置优先。
Vue 实例方法
ScrollItemExposed
| 方法 | 签名 | 说明 |
|---|---|---|
scrollToCenter | (selectedNode?: HTMLElement, scrollWrapper?: HTMLElement, duration?: number) => void | 将指定节点滚动到容器中心 |
scrollToIndex | (selectedIndex?: number, duration?: number) => void | 滚动到指定索引 |
scrollToNode | (node: HTMLElement, duration?: number) => void | 滚动到指定节点 |
scrollToPos | (targetTop: number, duration?: number) => void | 滚动到指定纵向位置 |
Vue 事件
ScrollItem
| 事件 | 参数 | 说明 |
|---|---|---|
| select | [data: ScrollItemSelectData] | 点击或滚动选中可用项时触发 |
Vue 插槽
ScrollList
| 插槽 | 作用域参数 | 说明 |
|---|---|---|
| default | {} | ScrollItem 子组件 |
| header | {} | 列表头部内容 |
| footer | {} | 列表底部内容 |
ScrollList
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| bodyHeight | body高度 | number | string | — |
| class | Vue 原生类名 | HTMLAttributes['class'] | — |
| className | 样式类名 | HTMLAttributes['class'] | — |
| footer | 底部 addon | VNodeChild | — |
| header | 头部 addon | VNodeChild | — |
| prefixCls | 样式类名前缀 | string | semi-scrolllist |
| style | 内联样式 | StyleValue | — |
ScrollItem
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| ariaLabel | aria-label 的类型化 Vue 映射 | string | — |
| class | Vue 原生类名 | HTMLAttributes['class'] | — |
| className | 样式类名 | HTMLAttributes['class'] | '' |
| cycled | 是否为无限循环,仅在 mode 为 "wheel" 时生效 | boolean | false |
| list | 列表内容 | Item[] | [] |
| mode | 模式选择 | ScrollItemMode | wheel |
| motion | 是否开启滚动动画 | ScrollMotion | true |
| selectedIndex | 选中项的索引 | number | 0 |
| style | 内联样式 | StyleValue | {} |
| transform | 对选中项的变换,返回值会作为文案进行显示 | (value: unknown, text: string) => unknown | — |
| type | — | number | string | — |
ItemData
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| disabled | 该项是否被禁止选择 | boolean | — |
| text | 每一项的文案 | string | — |
| transform | 该项处于选中状态时的变换,返回值会作为文案进行显示,ScrollItem 组件如果同时传入会优先选择 ItemData 中的 transform 方法 | (value: unknown, text: string) => unknown | — |
| value | 每一项的值 | unknown(必填) | — |
Accessibility
ARIA
ScrollItem支持传入aria-label, 指定该列标签ScrollItem使用aria-disabled表示该项目是否被禁用ScrollItem使用aria-selected表示该项目是否被选中