PullRefresh
A refresh container with asynchronous completion. Give its parent an explicit height. Standalone Vue also supports page scrolling.
Import
With uni-app easycom, use hui-pull-refresh。 Standalone Vue imports @nscode/handy-uni/web HuiPullRefresh or installs the preview plugin.
Examples
Interaction and event results
Interact with the control. The latest event and its full payload are shown below. Popup selectors commit only after confirmation; cancellation keeps the previous value.
<script setup lang="ts">
import { ref } from 'vue'
const result = ref('')
const items = ref([1, 2, 3])
const refresh = async () => {
items.value = [Date.now(), ...items.value]
return true
}
function event0(arg0: unknown) {
result.value = 'update:loading' + ': ' + JSON.stringify([arg0])
}
function event1() {
result.value = 'refresh' + ': ' + JSON.stringify([])
}
function event2(arg0: unknown) {
result.value = 'change' + ': ' + JSON.stringify([arg0])
}
function event3() {
result.value = 'reach-bottom' + ': ' + JSON.stringify([])
}
function event4(arg0: unknown) {
result.value = 'scroll' + ': ' + JSON.stringify([arg0])
}
</script>
<template>
<view style="height: 280px">
<hui-pull-refresh
:refresh="refresh"
@update:loading="event0"
@refresh="event1"
@change="event2"
@reach-bottom="event3"
@scroll="event4"
><view v-for="item in items" :key="item" style="padding: 20px">{{
item
}}</view></hui-pull-refresh
>
<text aria-live="polite">{{ result }}</text>
</view>
</template>
Behavior and platform support
On uni, container="page" warns during development and falls back to self. Use page-level enablePullDownRefresh with usePaging.refresh() and stop the native refresher after completion. disabled blocks gestures, while startRefresh() remains available.
Props
| Property | Type | Default | Description |
|---|---|---|---|
loading | boolean | undefined | undefined | Controlled refresh or loading state. |
default-loading | boolean | undefined | false | Initial refresh state. |
refresh | (() => unknown) | undefined | — | Refresh callback; false, throw and rejection display failure. |
disabled | boolean | undefined | false | Disable user interaction, including inherited form state. |
container | "self" | "page" | undefined | 'self' | self scrolling, or page scrolling in standalone Vue only. |
head-height | number | undefined | 50 | Refresh-head resting height in pixels. |
pull-distance | number | undefined | — | Release threshold in pixels, defaulting to headHeight. |
pulling-text | string | undefined | — | Pulling status text. |
loosing-text | string | undefined | — | Release-to-refresh status text. |
loading-text | string | undefined | — | Refreshing text. |
success-text | string | undefined | — | Success text; explicit empty text without a slot skips the result delay. |
failed-text | string | undefined | — | Failure text; explicit empty text without a slot skips the result delay. |
success-duration | number | undefined | 500 | Result-message duration in milliseconds. |
lower-threshold | number | undefined | 50 | Distance from scroll end in pixels before reach-bottom. |
custom-class | string | undefined | '' | Additional root classes. |
custom-style | string | CSSProperties | undefined | — | Additional root styles. |
Events
| Event | Parameters | Description |
|---|---|---|
update:loading | (loading: boolean) | Requests a controlled value update. |
refresh | () | Reports refresh with the arguments shown in the example. |
change | (info: { status: PullRefreshStatus; distance: number; }) | Reports change with the arguments shown in the example. |
reach-bottom | () | Reports reach-bottom with the arguments shown in the example. |
scroll | (info: { scrollTop: number; }) | Reports scroll with the arguments shown in the example. |
Slots
| Slot | Description |
|---|---|
default | Default content. |
pulling | Refresh-head scope: {distance}. |
loosing | Refresh-head scope: {distance}. |
loading | Refresh-head scope: {distance}. |
success | Refresh-head scope: {distance}. |
failed | Refresh-head scope: {distance}. |
Methods
| Method | Signature |
|---|---|
startRefresh | () => Promise<void> |
scrollTo | (top: number) => void |
Types
PullRefreshProps、PullRefreshEmits、PullRefreshExpose。 Public types are exported from the package entry.
Platform notes
| Scope | Behavior and validation limits |
|---|---|
| Shared implementation | The uni target uses the platform scroll refresher. Ordinary Vue detects top-edge pulls using touch direction locking. |
| Device checks pending | Check page/container scrolling, top-edge gating, loading exclusion and recovery; verify background scrolling on iOS devices. |
See examples/uni-demo/smoke/PullRefresh.md for the checklist. Unit tests do not replace device acceptance.