본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Loading Bar

원문 보기 위키 갱신

페이지 상단에 로딩 진행 바를 띄우는 컴포넌트예요. 데이터를 불러오는 동안 사용자에게 "진행 중"이라는 신호를 주는 좋은 위안제죠. provider로 감싸고 injection 메서드로 제어하는 구조예요.

출처: 문서

본문

불안을 달래 주는 좋은 위안제 중 하나예요.

loading bar를 사용하려면 관련 메서드를 호출하는 컴포넌트를 n-loading-bar-provider로 감싸고 loadingBar를 주입(inject)해야 해요. 예를 들면 다음과 같아요.
<!-- App.vue -->
<n-loading-bar-provider>
  <content />
</n-loading-bar-provider>
import { useLoadingBar } from 'naive-ui'
import { defineComponent } from 'vue'

// content
export default defineComponent({
  setup() {
    const loadingBar = useLoadingBar()
    return {
      loading() {
        loadingBar.start()
      }
    }
  }
})

Demos

basic.vue
container.vue

API

LoadingBarProvider Props

이름 타입 기본값 설명 버전
container-class string undefined loading bar 컨테이너의 클래스. 2.33.4
container-style string | object undefined loading bar 컨테이너의 스타일. 2.33.4
loading-bar-style { loading?: string | object, error?: string | object } undefined loading bar의 스타일.
to string | HTMLElement | false undefined loading bar의 마운트 타깃. 2.33.4

loadingBar Injection Methods

이름 타입 설명
error () => void loading bar 오류 시의 콜백 함수.
finish () => void loading bar가 로딩을 마쳤을 때의 콜백 함수.
start () => void loading bar에 로딩을 시작시키는 콜백 함수.

더 알아보기 (Learn more)

provider와 함께 쓰는 Message, Notification 같은 API는 각 컴포넌트 문서를 참고하세요. 컨테이너 위치 조정은 container 데모에서 확인할 수 있어요.