Cascader
계층적 데이터를 위한 계단식 선택 상자입니다.
사용 시기
- 계층적 구조의 집합에서 선택해야 할 때. 예를 들어 도/시/구, 회사 직급, 분류 등입니다.
- 대규모 데이터 세트에서 선택할 때 쉬운 선택을 위해 다단계 분류를 분리합니다.
- 더 나은 사용자 경험을 위해 하나의 플로트 레이어에서 계단식 항목을 선택합니다.
사용법
기본
도/시/구를 선택하기 위한 계단식 선택 상자입니다.
astro
---
import Cascader from '@/components/data-entry/Cascader.astro';
const options = [
{
value: 'zhejiang',
label: 'Zhejiang',
children: [
{
value: 'hangzhou',
label: 'Hangzhou',
children: [{ value: 'xihu', label: 'West Lake' }],
},
],
},
{
value: 'jiangsu',
label: 'Jiangsu',
children: [
{
value: 'nanjing',
label: 'Nanjing',
children: [{ value: 'zhonghuamen', label: 'Zhong Hua Men' }],
},
],
},
];
---
<Cascader options={options} placeholder="Please select" class="max-w-xs" /> 비활성화된 옵션
옵션에서 disabled 속성을 지정하여 옵션을 비활성화합니다.
astro
---
import Cascader from '@/components/data-entry/Cascader.astro';
const options = [
{
value: 'zhejiang',
label: 'Zhejiang',
children: [
{
value: 'hangzhou',
label: 'Hangzhou',
children: [{ value: 'xihu', label: 'West Lake' }],
},
],
},
{
value: 'jiangsu',
label: 'Jiangsu',
disabled: true,
children: [
{
value: 'nanjing',
label: 'Nanjing',
children: [{ value: 'zhonghuamen', label: 'Zhong Hua Men' }],
},
],
},
];
---
<Cascader options={options} placeholder="Please select" class="max-w-xs" /> 기본값
배열로 기본값을 지정합니다.
astro
---
import Cascader from '@/components/data-entry/Cascader.astro';
const options = [
{
value: 'zhejiang',
label: 'Zhejiang',
children: [
{
value: 'hangzhou',
label: 'Hangzhou',
children: [{ value: 'xihu', label: 'West Lake' }],
},
],
},
{
value: 'jiangsu',
label: 'Jiangsu',
children: [
{
value: 'nanjing',
label: 'Nanjing',
children: [{ value: 'zhonghuamen', label: 'Zhong Hua Men' }],
},
],
},
];
---
<Cascader options={options} value={['zhejiang', 'hangzhou', 'xihu']} placeholder="Please select" class="max-w-xs" /> API 참조
| 속성 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| options | The hierarchical options data. | CascaderOption[] | [] |
| placeholder | The input placeholder text. | string | "Select..." |
| value | The initial selected value path. | string[] | [] |