import{o as a,a as t,y as n}from"./vue-libs.b44bc779.js";const e={class:"van-doc-markdown-body"},l=n(`

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.

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.

<van-pull-refresh v-model="loading" @refresh="onRefresh">
  <p>Refresh Count: {{ count }}</p>
</van-pull-refresh>
import { ref } from 'vue';
import { Toast } from 'vant';

export default {
  setup() {
    const count = ref(0);
    const loading = ref(false);
    const onRefresh = () => {
      setTimeout(() => {
        Toast('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

<van-pull-refresh
  v-model="isLoading"
  success-text="Refresh success"
  @refresh="onRefresh"
>
  <p>Refresh Count: {{ count }}</p>
</van-pull-refresh>

Custom Tips

Use slots to custom tips.

<van-pull-refresh v-model="isLoading" :head-height="80" @refresh="onRefresh">
  <template #pulling="props">
    <img
      class="doge"
      src="https://fastly.jsdelivr.net/npm/@vant/assets/doge.png"
      :style="{ transform: \`scale(\${props.distance / 80})\` }"
    />
  </template>

  <template #loosing>
    <img
      class="doge"
      src="https://fastly.jsdelivr.net/npm/@vant/assets/doge.png"
    />
  </template>

  <template #loading>
    <img
      class="doge"
      src="https://fastly.jsdelivr.net/npm/@vant/assets/doge-fire.jpeg"
    />
  </template>
  <p>Refresh Count: {{ count }}</p>
</van-pull-refresh>

<style>
  .doge {
    width: 140px;
    height: 72px;
    margin-top: 8px;
    border-radius: 4px;
  }
</style>

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)number | string500
animation-durationAnimation durationnumber | string300
head-heightHeight of headnumber | string50
pull-distance v3.0.8The distance to trigger the pull refreshnumber | stringsame as head-height
disabledWhether to disable pull refreshbooleanfalse

Events

EventDescriptionParameters
refreshEmitted after pulling refresh-
change v3.5.1Emitted 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:

import type { 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-
`,14),p=[l],i={__name:"README",setup(d,{expose:s}){return s({frontmatter:{}}),(c,o)=>(a(),t("div",e,p))}};export{i as default};