# PullRefresh 당겨서 새로고침
당겨서 새로고침: 제스처 상태 기계 pulling → loosing → loading → success, 이동 거리 감쇠 변환
(dampenPull)과 당기기 가능 여부 판정(canPull)은 모두 @lh-ui/share/core/pull-refresh
순수 로직을 소비합니다. web 3개 끝은 touch 제스처를 직접 구현합니다.
당겨서 새로고침 (손을 떼면 트리거 + 성공 안내)
<template>
<div class="demo-col" style="gap: 18px">
<div class="pull-demo-scroll">
<LhPullRefresh v-model="refreshing" :head-height="50" @refresh="onRefresh">
<div v-for="item in items" :key="item" class="pull-demo-item">항목 {{ item }}</div>
</LhPullRefresh>
</div>
<p class="demo-note">{{ items.length }}건 · {{ times }}회 새로고침됨</p>
</div>
</template>
<script>
export default {
data: () => ({
refreshing: false,
items: [1, 2, 3],
times: 0,
}),
methods: {
onRefresh() {
setTimeout(() => {
this.times += 1
this.items = [1, 2, 3].map((i) => i + this.times * 3)
this.refreshing = false
}, 800)
},
},
}
</script>
# 사용자 정의 머리
head 이름 슬롯이 기본 텍스트 안내를 대체합니다(스코프 매개변수 { state }):
<LhPullRefresh v-model="refreshing">
<template #head="{ state }">
<span v-if="state === 'loading'">로딩 중…</span>
<span v-else>{{ state === 'loosing' ? '손을 떼면 새로고침' : '당겨서 새로고침' }}</span>
</template>
<div>콘텐츠</div>
</LhPullRefresh>
# 비활성화
<LhPullRefresh :model-value="false" disabled />
# Props
| 프로퍼티 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| modelValue | 새로고침 중 (제어, v-model; 사용 측이 데이터를 가져온 뒤 false로 설정) | boolean | false |
| headHeight | 머리 높이 / 트리거 임계값 px | number | 50 |
| pullingText | 당기기 안내 (미전달 시 언어 패키지 pullRefresh.pulling 사용) | string | — |
| loosingText | 해제 안내 (미전달 시 언어 패키지 pullRefresh.loosing 사용) | string | — |
| loadingText | 새로고침 중 안내 (미전달 시 언어 패키지 pullRefresh.loading 사용) | string | — |
| successText | 성공 안내 (미전달 시 언어 패키지 pullRefresh.success 사용) | string | — |
| disabled | 당겨서 새로고침 비활성화 | boolean | false |
| sx | sx 레이아웃 단축 속성 | LhSxProps | — |
# Events
| 이벤트 | 설명 | 페이로드 |
|---|---|---|
| update:modelValue | 새로고침 상태 변화 (새로고침 트리거 / 종료 되돌려 쓰기, v-model 경로) | value: boolean |
| refresh | 최상단에서 임계값을 넘겨 당긴 뒤 해제: 사용 측이 데이터를 가져온 뒤 modelValue=false로 설정 | — |
# Slots
| 슬롯 | 설명 |
|---|---|
| default | 페이지 콘텐츠 |
| head | 사용자 정의 머리 (스코프 매개변수 { state }) |
# 접근성
루트 요소 aria-busy가 새로고침 중을 반영합니다.
Copyright © 2024-2026 FengMo WenXue