For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/ui/components/list.md.
lynx-ui logo
lynx-ui
  • 简体中文
  • <List>

    一个适用于 ReactLynx 的虚拟化列表组件,用于高效渲染长列表数据。
    Info

    你可以查看源码来了解它的运行原理,也欢迎大家提 MR 来丰富其能力。

    基础用法

    ListProps

    Properties

    bounces
    iOS
    类型boolean·默认值true
    启用 iOS 弹性效果。
    children
    iOS
    Android
    Harmony
    类型ReactNode
    列表的子元素。
    className
    iOS
    Android
    Harmony
    类型string
    类名
    crossAxisGap
    iOS
    Android
    Harmony
    类型number·默认值0
    指定列表中组件的交叉轴间距。
    enableScroll
    iOS
    Android
    Harmony
    类型boolean·默认值true
    启用垂直滚动。
    enableScrollBar
    iOS
    Android
    Harmony
    类型boolean·默认值false
    启用滚动条。
    enableScrollMonitor
    iOS
    Android
    Harmony
    类型boolean·默认值false
    启用滚动监控。
    exposureID
    iOS
    Android
    Harmony
    类型string
    全局曝光的曝光ID
    exposureScene
    iOS
    Android
    Harmony
    类型string
    全局曝光的曝光场景
    initialScrollIndex
    iOS
    Android
    Harmony
    类型number·默认值0
    列表在初始加载时自动滚动到的位置。
    iosEnableSimultaneousTouch
    iOS
    类型boolean·默认值true
    强制触摸事件发送到列表。
    iosScrollsToTop
    iOS
    类型boolean·默认值true
    点击 iOS 状态栏时是否需要回顶。
    itemSnap
    iOS
    Android
    Harmony
    类型ListItemSnapAlignment
    分页滚动
    listId
    iOS
    Android
    Harmony
    类型string
    列表的 ID。
    listMaxSize
    iOS
    Android
    Harmony
    类型number
    单位是 px。设置容器的自适应高度限制。当子内容高度小于此值时,容器高度自动适应内容;当子内容超过此值时,容器高度将固定为该值并显示滚动条。
    listType
    iOS
    Android
    Harmony
    类型single | flow | waterfall
    列表的布局类型。
    lowerThresholdItemCount
    iOS
    Android
    Harmony
    类型number·默认值0
    下边缘触发 onScrollToLower 事件的条目阈值。
    main-thread:gesture
    iOS
    Android
    类型BaseGesture
    如果想使用gesture api,请传入该属性。
    mainAxisGap
    iOS
    Android
    Harmony
    类型number·默认值0
    指定列表中组件的主要轴间距。
    name
    iOS
    Android
    Harmony
    类型string
    列表的名称。
    needLayoutCompleteInfo
    iOS
    Android
    Harmony
    类型boolean·默认值false
    输出布局完成的详细信息。
    onUIAppear
    iOS
    Android
    Harmony
    类型(e: CommonEvent) => void
    UI 的曝光事件。
    onUIDisappear
    iOS
    Android
    Harmony
    类型(e: CommonEvent) => void
    UI 的消失事件。
    preloadBufferCount
    iOS
    Android
    Harmony
    类型number·默认值0
    控制列表在屏上节点之外,提前加载节点的个数。在 listType 为 waterfall 时不生效。
    ref
    类型ForwardedRef
    scrollEventThrottle
    iOS
    Android
    Harmony
    类型number·默认值200
    列表触发滚动事件回调的时间间隔(毫秒)。
    scrollMonitorTag
    iOS
    Android
    Harmony
    类型string·默认值false
    滚动监控的标签。
    scrollOrientation
    iOS
    Android
    Harmony
    类型vertical | horizontal·默认值'vertical'
    设置为 'vertical' 为垂直滚动,设置为 'horizontal' 为水平滚动。
    scrollPropagationBehavior
    iOS
    Android
    类型ScrollPropagationBehavior·默认值'native'
    控制滚动事件是否向父级容器传递。'preventPropagate' 在 iOS 上暂时需与 temporaryBlockScrollClass 和 temporaryBlockScrollTag 配合使用。 Currently, this property has its limits because the full ability has dependency on higher native SDK version. On iOS the 'propagate' only works when the both parent component and this component are set to 'propagate'. And useRefactorList={true} don't support 'propagate'. On Android, the 'preventPropagate' can only works when its parent element is x-swiper and x-viewpager-ng.
    shouldRequestStateRestore
    iOS
    Android
    Harmony
    类型boolean·默认值false
    元素层复用的生命周期。解决 UI 层复用状态混乱的问题。
    showVisibleItemInfoInScrollEvent
    iOS
    Android
    Harmony
    类型boolean·默认值false
    控制是否在绑定滚动事件中包含附加单元格信息。
    spanCount
    iOS
    Android
    Harmony
    类型number·默认值true
    列表的列数。
    stickyOffset
    iOS
    Android
    Harmony
    类型number·默认值0
    粘性位置与列表顶部或底部的偏移量。
    style
    iOS
    Android
    Harmony
    类型CSSProperties
    样式
    temporaryAndroidEnableOverflow
    Android
    类型boolean·默认值true
    是否开启 android 平台层 list overflow
    temporaryBlockScrollClass
    iOS
    类型string·默认值'BDXLynxViewPager'
    当 scrollPropagationBehavior 设为 'preventPropagate' 时,被阻止滚动的容器的具体类名。'preventPropagate' 在 iOS 上暂时需与 temporaryBlockScrollClass 和 temporaryBlockScrollTag 配合使用。 此为临时属性,将在新版 Lynx SDK 中废弃。
    temporaryBlockScrollTag
    iOS
    类型number·默认值0
    用于指定当 scrollPropagationBehavior 设为 'preventPropagate' 时被阻止滚动的原生容器标签(对应 UIView 的 Tag 属性)。该值需由原生容器提供方指定,且 'preventPropagate' 在 iOS 上暂时需与 temporaryBlockScrollClass 和 temporaryBlockScrollTag 配合使用。 此为临时属性,将在新版 Lynx SDK 中废弃。
    upperThresholdItemCount
    iOS
    Android
    Harmony
    类型number·默认值0
    上边缘触发 onScrollToUpper 事件的条目阈值。
    useRefactorList
    iOS
    Android
    Harmony
    类型boolean·默认值true
    使用重构后的列表。

    Events

    catchLongPress
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    与 onLongPress 相同,但会阻止事件冒泡。
    catchTouchCancel
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    与 onTouchCancel 相同,但会阻止事件冒泡。
    catchTouchEnd
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    与 onTouchEnd 相同,但会阻止事件冒泡。
    catchTouchMove
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    与 onTouchMove 相同,但会阻止事件冒泡。
    catchTouchStart
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    与 onTouchStart 相同,但会阻止事件冒泡。
    debugLogLevel
    iOS
    Android
    Harmony
    类型0 | 1 | 2 | 3·默认值0
    显示调试日志。0:无,1:错误,2:信息,3:详细
    onLayoutChange
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    当 UI 视口大小改变时发送。
    onLayoutComplete
    iOS
    Android
    Harmony
    类型(e: LayoutCompleteEvent) => void
    当列表的条目更新并且此更新过程已完成时发送。
    onLongPress
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    当触摸点在 UI 上按住一段时间后发送。
    onScroll
    iOS
    Android
    类型(e: ScrollEvent) => void
    滚动时触发。
    onScrollEnd
    iOS
    Android
    类型(e: [object Object] | undefined) => void·默认值undefined
    滚动停止时触发。
    onScrollStateChange
    iOS
    Android
    Harmony
    类型(e: ListScrollStateChangeEvent) => void
    滚动状态变更。
    onScrollToLower
    iOS
    Android
    类型(e: [object Object] | undefined) => void·默认值undefined
    滚动到底部时触发。
    onScrollToUpper
    iOS
    Android
    类型(e: [object Object] | undefined) => void·默认值undefined
    滚动到顶部时触发。
    onSnapToItem
    iOS
    Android
    Harmony
    类型(e: ListSnapEvent) => void
    当列表限位滚动到一个条目时发送。
    onTap
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    当触摸点在 UI 上轻触时发送。
    onTouchCancel
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    当触摸事件在完成前被中断或取消时发送。
    onTouchEnd
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    当触摸点从 UI 上移除时发送。
    onTouchMove
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    当触摸点在 UI 上移动时发送。
    onTouchStart
    iOS
    Android
    Harmony
    类型(e: EventHandler | undefined) => void
    当触摸点放置在 UI 上时发送。

    diffResultDetails

    insertions
    类型number[]
    move_from
    类型number[]
    move_to
    类型number[]
    removals
    类型number[]
    update_from
    类型number[]
    update_to
    类型number[]

    LayoutCompleteEvent

    detail
    iOS
    Android
    Harmony
    类型layoutCompleteEventDetail
    布局详情

    layoutCompleteEventDetail

    diffResult
    类型diffResultDetails
    layout-id
    iOS
    Android
    Harmony
    类型number
    与 setState 连接。
    visibleCellsAfterLayout
    类型ListItemInfo[]
    visibleCellsBeforeLayout
    类型ListItemInfo[]

    ListItemInfo

    height
    类型number
    isBinding
    类型boolean
    itemKey
    类型string
    originX
    类型number
    originY
    类型number
    updated
    类型boolean
    width
    类型number

    ListItemSnapAlignment

    factor
    iOS
    Android
    Harmony
    类型number
    分页定位锚定位置的参数,取值范围 [0, 1] 0 - 子节点与 List 的顶部对齐 1 - 子节点与 List 的底部对齐
    offset
    iOS
    Android
    Harmony
    类型number
    额外增加偏移参数,在 factor 的基础之上再进一步添加偏移量

    ListRef

    autoScroll
    iOS
    Android
    Harmony
    类型(rate: px | rpx | ppx | rem | em | vw | vh, start: boolean, autoStop: boolean) => void
    自动滚动列表到指定位置和偏移量。
    getVisibleCells
    iOS
    Android
    Harmony
    类型(success: (res: unknown) => void, fail: (res: unknown) => void) => void
    将列表滚动到指定位置和偏移量。
    scrollIntoID
    iOS
    Android
    Harmony
    类型(animated: boolean, alignTo: top | bottom | middle | none, listItemID: string, id: string, index: number, offset: number, success: (res: unknown) => void, fail: (res: unknown) => void) => void·默认值false
    扩展标准列表的 scrollTo 方法。此方法使用 worklet 并支持像 scroll-view 方法的参数 id。由于列表是懒加载的,此方法中需要索引以找到 id 组件的位置。需要 useRefactorList={true}
    scrollTo
    iOS
    Android
    Harmony
    类型(animated: boolean, alignTo: top | bottom | middle | none, index: number, offset: number, success: (res: unknown) => void, fail: (res: unknown) => void) => void·默认值0
    滚动列表到指定位置和偏移量。
    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。