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

Tree Select

원문 보기 위키 갱신

Tree Select (트리 셀렉트)

TreeSelect는 트리 구조로 된 데이터를 선택하는 컴포넌트예요. 원문에는 "99%의 사람들이 TreeSelect와 Cascader를 구분하지 못한다"는 농담이 나올 정도로 두 컴포넌트가 비슷해 보이지만, 실제 역할은 조금 달라요.

출처: 문서

본문

Demos

basic.vue
custom-field.vue
multiple.vue
checkbox.vue
check-strategy.vue
show-line.vue
filterable.vue
action.vue
async.vue
status.vue
file-picker.vue
debug.vue

API

TreeSelect Props

이름 타입 기본값 설명 버전
allow-checking-not-loaded boolean false 아직 로드되지 않은 노드에 대해서도 계층 체크(cascade checking)를 허용할지 여부예요. 이 기능을 쓰려면 value가 불완전해질 수 있다는 점을 알고 있어야 해요. 또한 disabled 노드가 있을 때를 특히, naive의 체크 로직과 여러분 백엔드의 체크 로직이 서로 일치하는지도 신경 써야 해요. 2.28.1
cascade boolean false 부모 노드와 자식 노드의 선택을 연동할지 여부예요.
checkable boolean false 체크박스로 값을 선택할지 여부예요.
check-strategy string 'all' 부모와 자식이 모두 선택됐을 때 선택된 노드를 어떻게 표시할지 정해요.
children-field string 'children' TreeSelectOption에서 사용할 children 속성이에요.
clearable boolean false 선택을 지울 수 있는지 여부예요.
clear-filter-after-select boolean true multiple과 filter가 true일 때, 옵션을 선택한 뒤 필터 키워드를 지울지 여부예요. 2.25.3
consistent-menu-width boolean true 선택 입력 영역과 메뉴의 너비를 강제로 같게 만들어요. *이 옵션을 쓰면 가상 스크롤이 비활성화돼요.
default-value string | number | Array<string | number> | null null 기본으로 선택되는 키(multiple일 때는 키 배열)예요.
default-expand-all boolean false 모든 노드를 기본으로 펼칠지 여부예요.
default-expanded-keys Array<string | number> [] 특정 키를 기본으로 펼쳐요.
disabled boolean false 비활성 상태 여부예요.
ellipsis-tag-popover-props PopoverProps undefined 말줄임 태그 preview의 popover props예요. 2.37.0
expanded-keys Array<string | number> undefined 펼쳐진 키들의 모음이에요.
indent number 24 트리의 한 단계당 들여쓰기 값이에요. 2.41.1
indeterminate-keys Array<string | number> undefined 트리의 indeterminate 키들이에요.
filterable boolean false 필터를 표시할지 여부예요.
filter (pattern: string, option: TreeSelectOption) => boolean - 필터 함수예요.
get-children (option: any) => unknown undefined 옵션의 children을 가져오는 함수예요. 2.38.1
key-field string 'key' TreeSelectOption에서 사용할 key 필드예요.
label-field string 'label' TreeSelectOption에서 사용할 label 필드예요.
disabled-field string 'disabled' TreeSelectOption에서 사용할 disabled 필드예요. 2.32.2
loading boolean false 로딩 중인지 여부예요. 2.28.3
max-tag-count number | 'responsive' undefined 목록이 잘리기 전까지 표시할 선택된 옵션의 최대 개수예요. 'responsive'를 쓰면 선택된 모든 옵션을 한 줄에 유지해요.
menu-props HTMLAttributes undefined 메뉴의 DOM props예요. 2.22.0
multiple boolean false 여러 옵션을 선택할 수 있게 해요.
node-props (info: { option: TreeSelectOption }) => HTMLAttributes undefined 노드의 HTML 속성이에요. 2.30.7
options TreeSelectOption[] [] 옵션 목록이에요.
override-default-node-click-behavior (info: { option: TreeSelectOption }) => 'toggleExpand' | 'toggleSelect' | 'toggleCheck' | 'default' | 'none' undefined 노드 클릭의 기본 동작을 재정의해요. 2.37.0
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' 트리 선택 메뉴의 위치예요. 2.25.0
render-label (info: { option: TreeSelectOption, checked: boolean, selected: boolean }) => VNodeChild undefined 모든 옵션의 label을 렌더링하는 함수예요. 2.30.7
render-prefix (info: { option: TreeSelectOption, checked: boolean, selected: boolean }) => VNodeChild undefined 모든 옵션의 prefix를 렌더링하는 함수예요. 2.30.7
render-suffix (info: { option: TreeSelectOption, checked: boolean, selected: boolean }) => VNodeChild undefined 모든 옵션의 suffix를 렌더링하는 함수예요. 2.30.7
render-switcher-icon () => VNodeChild undefined 옵션 스위처 아이콘을 렌더링하는 함수예요. 2.30.7
render-tag (props: { option: TreeSelectOption, handleClose: () => void }) => VNodeChild undefined 각 옵션 태그를 렌더링하는 함수예요. 2.30.7
separator string ' / ' 옵션 값을 구분하는 구분자예요.
show-line boolean false 트리 연결선을 표시할지 여부예요. 2.44.0
show-path boolean false label에 선택된 노드의 계층 경로도 함께 표시할지 여부예요.
size 'small' | 'medium' | 'large' 'medium' 컴포넌트 크기예요.
status 'success' | 'warning' | 'error' undefined 유효성 검사 상태예요. 2.27.0
to string | HTMLElement | false body 메뉴의 컨테이너 노드예요. false를 주면 메뉴를 분리(detach)하지 않아요.
value string | number | Array<string | number> | null> undefined 선택된 키(multiple일 때는 키 배열)예요.
virtual-scroll boolean true 가상 스크롤을 사용할지 여부예요.
watch-props Array<'defaultCheckedKeys' | 'defaultSelectedKeys' |'defaultExpandedKeys'> undefined 기본으로 감시할 prop 이름들이에요. prop이 바뀌면 컴포넌트가 갱신돼요. 주의: watch-props 자체는 반응형이 아니에요. 2.36.0
on-blur (e: FocusEvent) => void undefined 블러될 때 호출되는 콜백이에요.
on-focus (e: FocusEvent) => void undefined 포커스를 받을 때 호출되는 콜백이에요.
on-load (node: TreeSelectOption) => Promise<void> undefined 데이터를 비동기로 로드할 때 호출되는 콜백 함수예요. 2.27.0
on-update:expanded-keys (value: Array<string | number>, meta: { node: TreeOption | null, action: 'expand' | 'collapse' | 'filter' }) => void undefined 펼쳐진 키가 갱신될 때 호출되는 콜백이에요. meta 2.34.0
on-update:indeterminate-keys (keys: Array<string | number>) => void undefined indeterminate 옵션이 바뀔 때 호출되는 콜백 함수예요.
on-update:value (value: string | number | Array<string | number> | null, option: TreeSelectOption | null | Array<TreeSelectOption | null>, meta: { node: TreeOption | null, action: 'select' | 'unselect' | 'delete' | 'clear' }) => void) => void undefined 값이 갱신될 때 호출되는 콜백이에요.

TreeSelectOption Properties

이름 타입 설명 버전
key string | number 고유한 옵션 키예요. 사용할 필드는 key-field로 바꿀 수 있어요.
label string 옵션에 표시되는 내용이에요. 사용할 필드는 label-field로 바꿀 수 있어요.
children? TreeSelectOption[] 옵션의 자식 옵션이에요. 사용할 필드는 children-field로 바꿀 수 있어요.
disabled? boolean 옵션의 비활성 상태예요.
isLeaf? boolean 노드가 리프(leaf)인지 여부예요. 비동기 모드에서는 필수예요. 2.27.0

TreeSelect Slots

이름 파라미터 설명 버전
header () 메뉴 헤더 슬롯이에요. 2.40.0
action () 옵션 메뉴 슬롯이에요. 2.22.0
arrow () 트리거의 화살표 아이콘이에요. 2.30.4
empty () 옵션 메뉴의 빈 상태(empty) 슬롯이에요. 2.22.0

TreeSelect Methods

이름 타입 설명 버전
blur () => void 블러 처리해요. 2.34.0
blurInput () => void 입력 요소를 블러 처리해요. 2.35.0
focus () => void 포커스를 맞춰요. 2.34.0s
focusInput () => void 입력 요소에 포커스를 맞춰요. 2.35.0
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)

트리 형태 데이터를 다루는 다른 방법이 궁금하다면 Tree 컴포넌트와 Cascader 컴포넌트 문서를 함께 살펴보세요. 두 컴포넌트의 차이를 잡는 데 특히 도움이 돼요.