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
| Prop | Description | Type | Default |
|---|---|---|---|
| modelValue | Refreshing (controlled, v-model; the consumer sets it to false after pulling the data) | boolean | false |
| headHeight | Header height / trigger threshold in px | number | 50 |
| pullingText | Pull hint (falls back to the pullRefresh.pulling language pack when not passed) | string | — |
| loosingText | Release hint (falls back to the pullRefresh.loosing language pack when not passed) | string | — |
| loadingText | Refreshing hint (falls back to the pullRefresh.loading language pack when not passed) | string | — |
| successText | Success hint (falls back to the pullRefresh.success language pack when not passed) | string | — |
| disabled | Disable pull | boolean | false |
| sx | sx quick-layout props | LhSxProps | — |
Events
| Event | Description | Payload |
|---|---|---|
| update:modelValue | Refreshing state change (start / end refresh write-back, the v-model path) | value: boolean |
| refresh | Released after pulling past the threshold at the top: the consumer sets modelValue=false after pulling the data | — |
Slots
| Slot | Description |
|---|---|
| default | Page content |
| head | Custom 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=truedirectly - uniapp / wxapp: mapped to the scroll-view
refresher-enabled/refresher-triggeredevents (no hand-written gestures) - alipay: no scroll-view refresher; page-level
onPullDownRefresh(registered as page-level usage)

