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

Cascader

원문 보기 위키 갱신

Cascader (캐스케이더)

Cascader는 트리 구조로 된 데이터를 표시하고 선택할 때 사용하는 컴포넌트예요. 계층을 따라 내려가며 항목을 고르는 경로 선택 UX가 필요할 때 특히 잘 맞아요.

출처: 문서

본문

Demos

single.vue
multiple.vue
size.vue
single-lazy.vue
multiple-lazy.vue
action.vue
virtual.vue
check-strategy.vue
custom-field.vue
custom-render.vue
focus.vue
status.vue

API

Cascader Props

이름 타입 기본값 설명 버전
allow-checking-not-loaded boolean false 아직 로드되지 않은 노드에 대해서도 계층 체크(cascade checking)를 허용할지 여부예요. 이 기능을 쓰려면 value가 불완전해질 수 있다는 점을 알고 있어야 해요. 또한 disabled 노드가 있을 때를 특히, naive의 체크 로직과 여러분 백엔드의 체크 로직이 서로 일치하는지도 신경 써야 해요. 2.28.1
cascade boolean true 체크박스 선택을 자식 노드로 연결(cascade)할지 여부예요.
check-strategy string 'all' 체크된 옵션을 표시하는 방식이에요. all은 체크된 모든 노드를 표시해요. parent는 모든 자식 노드가 체크됐을 때 체크된 부모 노드를 표시해요(단일 선택 모드에서는 동작하지 않아요). child는 자식 노드 전부를 표시해요.
children-field string 'children' CascaderOption의 children 필드예요.
clearable boolean false Cascader를 지울 수 있는지 여부예요.
clear-filter-after-select boolean true multiple과 filter가 true일 때, 옵션을 선택한 뒤 필터 키워드를 지울지 여부예요. 2.25.3
default-value string | number | Array<number | string> | null null value가 설정되어 있지 않을 때 기본으로 선택되는 데이터예요.
disabled boolean false Cascader를 비활성화할지 여부예요.
disabled-field string 'disabled' CascaderOption의 disabled 필드예요. 2.32.2
ellipsis-tag-popover-props PopoverProps undefined 말줄임 태그 preview의 popover props예요. 2.37.0
expand-trigger 'click' | 'hover' 'click' remote가 설정되어 있으면 'hover'는 동작하지 않아요.
filterable boolean false 주의: remote가 설정되어 있으면 이 prop은 아무 효과가 없어요.
filter (pattern: string, option: CascaderOption, path: CascaderOption[]) => boolean 문자열 기반 필터 알고리즘. Cascader의 필터 함수예요.
filter-menu-props HTMLAttributes undefined 필터 메뉴의 DOM props예요. 2.27.0
get-column-style (detail: { level: number }) => string | object undefined 컬럼 스타일을 결정하는 함수예요. level은 0부터 시작해요. 2.38.2
value-field string 'value' CascaderOption의 value 필드예요.
label-field string 'label' CascaderOption의 label 필드예요.
max-tag-count number | 'responsive' undefined 다중 선택 모드에서 표시할 태그의 최대 개수예요. responsive를 쓰면 모든 태그를 한 줄에 유지해요.
menu-props HTMLAttributes undefined 메뉴의 DOM props예요. 2.27.0
multiple boolean false 여러 옵션을 선택할 수 있게 할지 여부예요.
options CascaderOption[] [] Cascader의 옵션이에요.
placeholder string 'Please Select' 플레이스홀더 텍스트예요.
placement 'top-start' | 'top' | 'top-end' | 'right-start' | 'right' | 'right-end' | 'bottom-start' | 'bottom' | 'bottom-end' | 'left-start' | 'left' | 'left-end' 'bottom-start' Cascader의 위치예요. 2.25.0
remote boolean false 데이터를 원격에서 가져올지 여부예요.
render-prefix (info: { option: CascaderOption, node: VNode | null, checked: boolean }) => VNodeChild undefined 모든 옵션의 prefix를 렌더링하는 함수예요. 2.38.2
render-label (option: CascaderOption, checked: boolean) => VNodeChild undefined Cascader 메뉴 옵션의 label을 렌더링하는 함수예요. 2.24.0
render-suffix (info: { option: CascaderOption, node: VNode | null, checked: boolean }) => VNodeChild undefined 모든 옵션의 suffix를 렌더링하는 함수예요. 2.38.2
scrollbar-props ScrollbarProps undefined Scrollbar props를 참고하세요. 2.44.0
separator string ' / ' 선택된 옵션 경로 값의 구분자예요(show-path와 함께 사용해요).
show boolean undefined 메뉴를 표시할지 여부예요.
show-path boolean true 선택된 옵션을 경로 형태로 표시할지 여부예요.
size 'small' | 'medium' | 'large' 'medium' Cascader의 크기예요.
spin-props { strokeWidth?: number, stroke?: string, scale?: number, radius?: number } undefined 로딩 아이콘 속성이에요. 2.44.0
status 'success' | 'warning' | 'error' undefined 유효성 검사 상태예요. 2.27.0
to string | HTMLElement | false body 메뉴의 컨테이너 노드예요. false를 주면 메뉴를 분리(detach)하지 않아요.
value string | number | Array<number | string> | null undefined Cascader의 값(수동으로 설정하는 경우)이에요.
virtual-scroll boolean true 가상 스크롤을 사용할지 여부예요.
on-blur () => void undefined 블러될 때 호출되는 콜백이에요.
on-focus () => void undefined 포커스를 받을 때 호출되는 콜백이에요.
on-load (option: CascaderOption) => Promise<void> undefined 노드가 로드될 때 호출되는 콜백이에요. 반환하는 promise에서 option.children을 지정해요. promise가 resolve되거나 reject되면 로딩이 멈춰요.
on-update:show (value: boolean) => void undefined 메뉴가 열리고 닫힐 때 실행되는 콜백이에요.
on-update:value (value: string | number | Array<string | number> | null, option: CascaderOption | Array<CascaderOption | null> | null, pathValues: Array<CascaderOption | null> | Array<CascaderOption[] | null> | null) => void undefined 값이 바뀔 때 실행되는 콜백이에요.

CascaderOption Properties

이름 타입 설명 버전
label string 옵션의 label이에요.
value string | number 옵션의 value예요.
disabled? boolean 이 옵션이 비활성 상태인지 여부예요.
children? CascaderOption 이 옵션의 자식 옵션이에요.

Cascader Slots

이름 파라미터 설명 버전
action () 캐스케이딩 메뉴에 표시되는 액션 콘텐츠예요.
arrow () 캐스케이딩 메뉴에 표시되는 화살표 콘텐츠예요. 2.32.2
empty () 옵션 캐스케이딩 메뉴의 빈 상태(empty) 슬롯이에요. 2.22.0
not-found () 검색 중에 데이터를 찾지 못했을 때 표시되는 슬롯이에요. 2.34.0

Cascader Methods

이름 타입 설명 버전
blur () => void 블러 처리해요. 2.24.2
focus () => void 포커스를 맞춰요. 2.24.2
getCheckedData () => { keys: Array<string | number>, options: Array<TreeOption | null> } 체크된 데이터를 가져와요. 2.34.0
getIndeterminateData () => { keys: Array<string | number>, options: Array<TreeOption | null> } indeterminate 데이터를 가져와요. 2.34.0

더 알아보기 (Learn more)

비슷한 트리 기반 선택 UI인 Tree Select도 함께 살펴보면 두 컴포넌트의 차이를 잡는 데 도움이 돼요. 검색과 필터가 중요하다면 Select 문서도 참고하세요.