Skip to content

PullRefresh - Vant 4

PullRefresh

Intro

Used to provide interactive operations for pull-down refresh.

Install

Register component globally via app.use, refer to Component Registration for more registration ways.

js
import { createApp } from'vue'; import { PullRefresh } from'vant'; const app = createApp(); app.use(PullRefresh);

Usage

Basic Usage

The refresh event will be Emitted when pull refresh, you should set v-model to false to reset loading status after process refresh event.

html
js
import { ref } from'vue'; import { showToast } from'vant'; exportdefault { setup() { const count = ref(0); const loading = ref(false); constonRefresh = () => { setTimeout(() => { showToast('Refresh Success'); loading.value = false; count.value++; }, 1000); }; return { count, loading, onRefresh, }; }, };

Success Tip

Use success-text to set the success prompt after the refresh is successful

html

Custom Tips

Use slots to custom tips.

html

API

Props

AttributeDescriptionTypeDefault
v-modelLoading statusboolean-
pulling-textText to show when pullingstringPull to refresh...
loosing-textText to show when loosingstringLoose to refresh...
loading-textText to show when loadingstringLoading...
success-textText to show when loading successstring-
success-durationSuccess text display duration(ms)*numberstring*
animation-durationAnimation duration*numberstring*
head-heightHeight of head*numberstring*
pull-distanceThe distance to trigger the pull refresh*numberstring*
disabledWhether to disable pull refreshbooleanfalse

Events

EventDescriptionParameters
refreshEmitted after pulling refresh-
changeEmitted when draging or status changed{ status: string, distance: number }

Slots

NameDescriptionSlotProps
defaultDefault slot-
normalContent of head when at normal status-
pullingContent of head when at pulling{ distance: number }
loosingContent of head when at loosing{ distance: number }
loadingContent of head when at loading{ distance: number }
successContent of head when succeed-

Types

The component exports the following type definitions:

ts
importtype { PullRefreshProps } from'vant';

Theming

CSS Variables

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

NameDefault ValueDescription
--van-pull-refresh-head-height50px-
--van-pull-refresh-head-font-sizevar(--van-font-size-md)-
--van-pull-refresh-head-text-colorvar(--van-text-color-2)-
--van-pull-refresh-loading-icon-size16px-

Enterprise-level mobile solution based on Vant