Skip to content
API 风格:

PullRefresh ​

Pull-to-refresh: a gesture state machine pulling → loosing → loading → success. The displacement damping computation (dampenPull) and the top-hit check (canPull) all consume the pure logic in @lh-ui/share/core/pull-refresh. The three web platforms use hand-written touch gestures; uniapp/wxapp map to scroll-view refresher events; alipay uses the page-level onPullDownRefresh (registered as page-level usage).

Basic Usage ​

Pull to refresh (release to trigger + success hint)
Pull down to refresh
Item 1
Item 2
Item 3

3 items · refreshed 0 times

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

const refreshing = ref(false)
const items = ref([1, 2, 3])
const times = ref(0)

function onRefresh() {
  setTimeout(() => {
    times.value += 1
    items.value = [1, 2, 3].map((i) => i + times.value * 3)
    refreshing.value = false // Set to false after the pull; it auto-resets after the success hint
  }, 800)
}
</script>

<template>
  <LhPullRefresh v-model="refreshing" @refresh="onRefresh">
    <div v-for="item in items" :key="item">Item {{ item }}</div>
  </LhPullRefresh>
</template>

Custom header ​

The head named slot replaces the default text hints (scoped prop { state }):

vue
<LhPullRefresh v-model="refreshing">
  <template #head="{ state }">
    <span v-if="state === 'loading'">Loading…</span>
    <span v-else>{{ state === 'loosing' ? 'Release to refresh' : 'Pull to refresh' }}</span>
  </template>
  <div>Content</div>
</LhPullRefresh>

Disabled ​

vue
<LhPullRefresh :model-value="false" disabled />

Props ​

PropDescriptionTypeDefault
modelValueRefreshing (controlled, v-model; the consumer sets it to false after pulling the data)booleanfalse
headHeightHeader height / trigger threshold in pxnumber50
pullingTextPull hint (falls back to the pullRefresh.pulling language pack when not passed)string—
loosingTextRelease hint (falls back to the pullRefresh.loosing language pack when not passed)string—
loadingTextRefreshing hint (falls back to the pullRefresh.loading language pack when not passed)string—
successTextSuccess hint (falls back to the pullRefresh.success language pack when not passed)string—
disabledDisable pullbooleanfalse
sxsx quick-layout propsLhSxProps—

Events ​

EventDescriptionPayload
update:modelValueRefreshing state change (start / end refresh write-back, the v-model path)value: boolean
refreshReleased after pulling past the threshold at the top: the consumer sets modelValue=false after pulling the data—

Slots ​

SlotDescription
defaultPage content
headCustom header (scoped prop { state })

Accessibility ​

The root element's aria-busy reflects refreshing.

Cross-platform differences ​

  • The three web platforms: touch gestures (the nearest scrollable ancestor is detected automatically; when scrollTop is not 0, scrolling takes over); mouse dragging is not implemented on desktop — to trigger imperatively, just set modelValue=true directly
  • uniapp / wxapp: mapped to the scroll-view refresher-enabled / refresher-triggered events (no hand-written gestures)
  • alipay: no scroll-view refresher; page-level onPullDownRefresh (registered as page-level usage)

Beauty of tradition, foundation of code