# List

Infinite scroll list with bottom-hit loading: bottom-hit detection and the state machine (idle → loading → finished / error) all consume @lh-ui/share/core/list. The scroll container is auto-detected (the nearest scrollable ancestor, or window when there is none) and checked frame by frame with rAF throttling. The loading indicator reuses the spinner component.

Bottom-hit loading (with error retry and empty state)
<template>
  <div class="demo-col" style="gap: 18px">
    <div class="list-demo-scroll">
      <LhList
        :loading="loading"
        :finished="finished"
        :error="error"
        empty-text="No orders yet"
        @load="onLoad"
        @update:error="error = $event"
      >
        <div v-for="item in items" :key="item" class="list-demo-item">Order {{ item }}</div>
      </LhList>
    </div>
    <p class="demo-note">{{ items.length }} items loaded (8 per page, 20 in total; the first bottom hit simulates a failure you can retry)</p>
  </div>
</template>

<script>
export default {
  data: () => ({
    items: [],
    loading: false,
    finished: false,
    error: false,
    attempts: 0,
  }),
  methods: {
    onLoad() {
      this.attempts += 1
      if (this.attempts === 1) {
        this.error = true
        return
      }
      this.loading = true
      setTimeout(() => {
        for (let i = 0; i < 8; i += 1) this.items.push(this.items.length + 1)
        this.loading = false
        if (this.items.length >= 20) this.finished = true
      }, 600)
    },
  },
}
</script>

# Props

Prop Description Type Default
loading Loading (set to true before fetching data, back to false when done) boolean false
finished No more data (renders the locale message or the finished slot at the bottom) boolean false
error Load failed (renders a retry entry at the bottom) boolean false
offset Bottom-hit advance distance in px number 100
immediateCheck Run a bottom-hit check once right after mount boolean true
emptyText Empty-state text (rendered when finished and there is no content) string —
ariaLabel Accessibility name string —
sx sx shorthand layout props — —

# Events

Event Description Callback args
load Bottom hit (the consumer flips loading / finished after fetching data) ()
update:error Retry-click write-back (the controlled error is cleared) (value: boolean)

# Slots

Slot Description
default List content
loading Loading indicator (spinner by default)
finished "No more" message (defaults to the locale message list.finished)
error Error area (a retry entry "Load failed, tap to retry" by default)
empty Empty state (renders emptyText by default)

# Accessibility

  • The root element's aria-busy reflects the loading state; the accessible name comes from ariaLabel
Last Updated: 12/4/2026, 12:49:57 AM

Copyright © 2024-2026 FengMo WenXue