Skip to content

List ​

Infinite scroll list with bottom detection: the state machine (idle → loading → finished / error, error shown first) and class / aria mapping come entirely from @lh-ui/share/core/list; bottom detection is carried by a self-rendered scroll-view (scroll-y + lower-threshold), with the spinner reused for loading.

Platform difference (registered): this end renders its own scroll-view as the scroll carrier (web ends observe the nearest scrollable ancestor); the height prop sizes the scroll container; for page-level scrolling, drive the state yourself via the page's onReachBottom (the component works controlled). Content count is unavailable (the MP runtime cannot enumerate default-slot children), so the emptyText empty state does not auto-render on this end (use finished + your own lh-empty if needed).

Basic usage ​

vue
<template>
  <lh-list
    :loading="loading"
    :finished="finished"
    :error="error"
    :height="260"
    empty-text="No orders"
    @load="onLoad"
    @update:error="error = $event"
  >
    <view v-for="item in items" :key="item" class="item">Order {{ item }}</view>
  </lh-list>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const items = ref<number[]>([])
const loading = ref(false)
const finished = ref(false)
const error = ref(false)

function onLoad() {
  loading.value = true
  setTimeout(() => {
    for (let i = 0; i < 8; i += 1) items.value.push(items.value.length + 1)
    loading.value = false
    if (items.value.length >= 20) finished.value = true
  }, 600)
}
</script>

Props ​

PropDescriptionTypeDefault
loadingLoading (set true before fetching, false after)booleanfalse
finishedNo more items (footer renders locale text or the finished slot)booleanfalse
errorLoad failed (footer renders retry entry)booleanfalse
offsetBottom threshold px (scroll-view's lower-threshold)number100
immediateCheckCheck on mount whether content fills the screen (trigger load if not)booleantrue
heightScroll container height (constrained by the parent when omitted)number | string—
emptyTextEmpty text (not auto-rendered on this end, see platform difference)string—
ariaLabelAccessible namestring—
customClassCustom class (root node)string—
sxShorthand layout props——

Events ​

EventDescriptionPayload
loadReached bottom (set loading / finished after fetching)—
update:errorRetry click write-back (clears the controlled error)(value: boolean)

Slots ​

NameDescription
defaultList content
loadingLoading indicator (spinner by default)
finished"No more items" text (locale key list.finished by default)
errorError area (default "Failed to load, tap to retry" entry)
emptyEmpty state (renders emptyText by default)

Accessibility ​

  • Root node aria-busy reflects loading; accessible name from ariaLabel