Skip to content

PullRefresh ​

Pull to refresh: a gesture state machine pulling → loosing → loading → success, with distance math and the state machine fully consumed from @lh-ui/share/core/pull-refresh. The scroll carrier is a self-rendered scroll-view (refresher-enabled props; no manual gestures on this platform).

Platform differences (registered): uniapp/wxapp map scroll-view refresher events; alipay has no refresher and degrades to page-level onPullDownRefresh (registered as page-level usage); web uses touch gestures.

Basic usage ​

vue
<template>
  <lh-pull-refresh v-model="refreshing" :head-height="50" @refresh="onRefresh">
    <view v-for="item in items" :key="item">Item {{ item }}</view>
  </lh-pull-refresh>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const refreshing = ref(false)
const items = ref<number[]>([1, 2, 3])

function onRefresh() {
  setTimeout(() => {
    items.value = [1, 2, 3].map((i) => i + 3)
    refreshing.value = false
  }, 800)
}
</script>

Custom head ​

The head named slot replaces the default text hint (scoped param { state }):

vue
<lh-pull-refresh v-model="refreshing">
  <template #head="{ state }">
    <text v-if="state === 'loading'">Loading…</text>
    <text v-else>Pull to refresh</text>
  </template>
  <view>Content</view>
</lh-pull-refresh>

Disabled ​

vue
<lh-pull-refresh :model-value="false" disabled />

Props ​

NameDescriptionTypeDefault
modelValueRefreshing (controlled, v-model)booleanfalse
headHeightHead height / trigger threshold px (maps refresher-threshold)number50
pullingTextPulling hint (defaults to locale pullRefresh.pulling)string—
loosingTextRelease hint (defaults to locale pullRefresh.loosing)string—
loadingTextLoading hint (defaults to locale pullRefresh.loading)string—
successTextSuccess hint (defaults to locale pullRefresh.success)string—
disabledDisable pull (refresher-enabled=false)booleanfalse
customClassCustom class (forwarded to the root node)string—
sxQuick layout propsLhSxProps—

Events ​

EventDescriptionPayload
update:modelValueRefreshing state change (write-back, v-model path)value: boolean
refreshTriggered at top: set modelValue=false after fetching—

Slots ​

NameDescription
defaultPage content
headCustom head (scoped param { state })

Accessibility ​

The root node reflects loading via aria-busy.