Skip to content
API 风格:

List ​

Scrolling list with bottom-loading: the bottom-hit detection and state machine (idle → loading → finished / error) all consume @lh-ui/share/core/list; the scroll container is detected automatically (the nearest scrollable ancestor, otherwise window), throttled to one check per frame via rAF. The loading indicator reuses the spinner component.

Basic Usage ​

Basic usage (bottom loading + no more items)

0 items loaded; scrolling to the bottom triggers load (8 per page, 20 in total)

vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhList } from '@lh-ui/vue3'

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>

<template>
<div class="list-demo-scroll">
  <LhList v-model:error="error" :loading="loading" :finished="finished" @load="onLoad">
    <div v-for="item in items" :key="item" class="list-demo-item">Order {{ item }}</div>
  </LhList>
</div>
</template>
vue
<script>
import { LhList } from '@lh-ui/vue3'

export default {
  components: { LhList },
  data() {
    return { items: [], loading: false, finished: false, error: false }
  },
  methods: {
    onLoad() {
      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>

<template>
<div class="list-demo-scroll">
  <LhList v-model:error="error" :loading="loading" :finished="finished" @load="onLoad">
    <div v-for="item in items" :key="item" class="list-demo-item">Order {{ item }}</div>
  </LhList>
</div>
</template>

Error and empty states ​

Load failure (tap to retry) and empty-state text

The first bottom-hit simulates a failure (tap "Retry" to recover); when the data is empty, emptyText is shown

vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhList } from '@lh-ui/vue3'

const failItems = ref<number[]>([])
const failError = ref(false)
const failFinished = ref(false)
const attempts = ref(0)

function onFailLoad() {
  attempts.value += 1
  if (attempts.value === 1) {
    failError.value = true
    return
  }
  failFinished.value = true
}
</script>

<template>
<div class="list-demo-scroll">
  <LhList :error="failError" :finished="failFinished" empty-text="No orders yet" @update:error="failError = $event" @load="onFailLoad">
    <div v-for="item in failItems" :key="item" class="list-demo-item">Order {{ item }}</div>
  </LhList>
</div>
</template>
vue
<script>
import { LhList } from '@lh-ui/vue3'

export default {
  components: { LhList },
  data() {
    return { failItems: [], failError: false, failFinished: false, attempts: 0 }
  },
  methods: {
    onFailLoad() {
      this.attempts += 1
      if (this.attempts === 1) {
        this.failError = true
        return
      }
      this.failFinished = true
    },
  },
}
</script>

<template>
<div class="list-demo-scroll">
  <LhList :error="failError" :finished="failFinished" empty-text="No orders yet" @update:error="failError = $event" @load="onFailLoad">
    <div v-for="item in failItems" :key="item" class="list-demo-item">Order {{ item }}</div>
  </LhList>
</div>
</template>

List API ​

Props ​

PropDescriptionTypeDefault
loadingLoading (set to true before pulling data, false after completion)booleanfalse
finishedNo more items (renders the language-pack text or the finished slot at the bottom)booleanfalse
errorLoad failure (renders a retry entry at the bottom)booleanfalse
offsetBottom-hit advance in pxnumber100
immediateCheckRun a bottom-hit check immediately after mountbooleantrue
emptyTextEmpty-state text (rendered when finished and there is no content)string—
ariaLabelAccessible namestring—
sxsx quick-layout propsLhSxProps—

Events ​

EventDescriptionCallback
loadBottom hit (the consumer flips loading / finished after pulling data)[]
update:errorRetry tap write-back (controlled error cleared)(value: boolean)

Slots ​

SlotDescription
defaultList content
loadingLoading indicator (spinner by default)
finished"No more items" text (goes through the list.finished language pack by default)
errorError area (a "Load failed, tap to retry" retry entry by default)
emptyEmpty state (renders emptyText by default)

Accessibility ​

  • The root element's aria-busy reflects loading; the accessible name comes from ariaLabel

Beauty of tradition, foundation of code