代码演示

如何引入

jsx
import { ScrollList, ScrollItem } from '@kousum/semi-ui-vue';

基本使用

滚动列表提供了一个类似于 iOS 操作系统的滚动选择模式,同时支持滚动至指定窗口位置选择与点击选择。

demoApp.vue
demo.tsx
tsconfig.json
Import Map
Show Error
Auto Save

API 参考

ScrollList

属性说明类型默认值
bodyHeightbody高度string | number
className样式类名string''
footer底部 addonReactNode''
header头部 addonReactNode''
style内联样式CSSProperties{}

ScrollItem

属性说明类型默认值
className样式类名string''
cycled是否为无限循环,仅在 mode 为 "wheel" 时生效booleanfalse
list列表内容ItemData[][]
mode模式选择"normal" | "wheel""wheel"
motion是否开启滚动动画Motiontrue
onSelect选中回调(data: ItemData) => voidNOOP
selectIndex选中项的索引number0
style内联样式CSSProperties{}
transform对选中项的变换,返回值会作为文案进行显示(value: any, text: string) => stringv => v

ItemData

属性说明类型默认值
disabled该项是否被禁止选择boolean
text每一项的文案string
transform该项处于选中状态时的变换,返回值会作为文案进行显示,ScrollItem 组件如果同时传入会优先选择 ItemData 中的 transform 方法(value: any, text: string) => stringv => v
value每一项的值any

Accessibility

ARIA

  • ScrollItem 支持传入 aria-label, 指定该列标签
  • ScrollItem 使用 aria-disabled 表示该项目是否被禁用
  • ScrollItem 使用 aria-selected 表示该项目是否被选中

设计变量

变量默认值用法
$color-scrollList-bgvar(--semi-color-bg-3)滚动列表背景色
$color-scrollList-bordervar(--semi-color-border)滚动列表描边颜色
$color-scrollList_header-titlevar(--semi-color-text-0)滚动列表标题颜色
$color-scrollList_item-bgtransparent滚动列表选项背景色
$color-scrollList_item-textvar(--semi-color-text-0)滚动列表选项文字颜色
$color-scrollList_disabled_item-textvar(--semi-color-disabled-text)滚动列表选项背景色 - 禁用
$color-scrollList_item-text-hovervar(--semi-color-fill-1)滚动列表选项文字颜色 - 悬浮
$color-scrollList_item-bg-activevar(--semi-color-fill-2)滚动列表选项文字颜色 - 选中
$color-scrollList_selected_item-bgvar(--semi-color-primary-light-default)滚动列表选中选项背景颜色
$color-scrollList_selected_item-textvar(--semi-color-text-0)滚动列表选中选项文字颜色
显示第 1 条-第 10 条,共 12 条
  • 1
  • 2