Element Cascader 級聯(lián)選擇器的使用示例
組件—級聯(lián)選擇器
基礎(chǔ)用法

<div class="block">
<span class="demonstration">默認(rèn) click 觸發(fā)子菜單</span>
<el-cascader
v-model="value"
:options="options"
@change="handleChange"></el-cascader>
</div>
<div class="block">
<span class="demonstration">hover 觸發(fā)子菜單</span>
<el-cascader
v-model="value"
:options="options"
:props="{ expandTrigger: 'hover' }"
@change="handleChange"></el-cascader>
</div>
<script>
export default {
data() {
return {
value: [],
options: [{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '設(shè)計(jì)原則',
children: [{
value: 'yizhi',
label: '一致'
}, {
value: 'fankui',
label: '反饋'
}, {
value: 'xiaolv',
label: '效率'
}, {
value: 'kekong',
label: '可控'
}]
}, {
value: 'daohang',
label: '導(dǎo)航',
children: [{
value: 'cexiangdaohang',
label: '側(cè)向?qū)Ш?
}, {
value: 'dingbudaohang',
label: '頂部導(dǎo)航'
}]
}]
}, {
value: 'zujian',
label: '組件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}, {
value: 'color',
label: 'Color 色彩'
}, {
value: 'typography',
label: 'Typography 字體'
}, {
value: 'icon',
label: 'Icon 圖標(biāo)'
}, {
value: 'button',
label: 'Button 按鈕'
}]
}, {
value: 'form',
label: 'Form',
children: [{
value: 'radio',
label: 'Radio 單選框'
}, {
value: 'checkbox',
label: 'Checkbox 多選框'
}, {
value: 'input',
label: 'Input 輸入框'
}, {
value: 'input-number',
label: 'InputNumber 計(jì)數(shù)器'
}, {
value: 'select',
label: 'Select 選擇器'
}, {
value: 'cascader',
label: 'Cascader 級聯(lián)選擇器'
}, {
value: 'switch',
label: 'Switch 開關(guān)'
}, {
value: 'slider',
label: 'Slider 滑塊'
}, {
value: 'time-picker',
label: 'TimePicker 時(shí)間選擇器'
}, {
value: 'date-picker',
label: 'DatePicker 日期選擇器'
}, {
value: 'datetime-picker',
label: 'DateTimePicker 日期時(shí)間選擇器'
}, {
value: 'upload',
label: 'Upload 上傳'
}, {
value: 'rate',
label: 'Rate 評分'
}, {
value: 'form',
label: 'Form 表單'
}]
}, {
value: 'data',
label: 'Data',
children: [{
value: 'table',
label: 'Table 表格'
}, {
value: 'tag',
label: 'Tag 標(biāo)簽'
}, {
value: 'progress',
label: 'Progress 進(jìn)度條'
}, {
value: 'tree',
label: 'Tree 樹形控件'
}, {
value: 'pagination',
label: 'Pagination 分頁'
}, {
value: 'badge',
label: 'Badge 標(biāo)記'
}]
}, {
value: 'notice',
label: 'Notice',
children: [{
value: 'alert',
label: 'Alert 警告'
}, {
value: 'loading',
label: 'Loading 加載'
}, {
value: 'message',
label: 'Message 消息提示'
}, {
value: 'message-box',
label: 'MessageBox 彈框'
}, {
value: 'notification',
label: 'Notification 通知'
}]
}, {
value: 'navigation',
label: 'Navigation',
children: [{
value: 'menu',
label: 'NavMenu 導(dǎo)航菜單'
}, {
value: 'tabs',
label: 'Tabs 標(biāo)簽頁'
}, {
value: 'breadcrumb',
label: 'Breadcrumb 面包屑'
}, {
value: 'dropdown',
label: 'Dropdown 下拉菜單'
}, {
value: 'steps',
label: 'Steps 步驟條'
}]
}, {
value: 'others',
label: 'Others',
children: [{
value: 'dialog',
label: 'Dialog 對話框'
}, {
value: 'tooltip',
label: 'Tooltip 文字提示'
}, {
value: 'popover',
label: 'Popover 彈出框'
}, {
value: 'card',
label: 'Card 卡片'
}, {
value: 'carousel',
label: 'Carousel 走馬燈'
}, {
value: 'collapse',
label: 'Collapse 折疊面板'
}]
}]
}, {
value: 'ziyuan',
label: '資源',
children: [{
value: 'axure',
label: 'Axure Components'
}, {
value: 'sketch',
label: 'Sketch Templates'
}, {
value: 'jiaohu',
label: '組件交互文檔'
}]
}]
};
},
methods: {
handleChange(value) {
console.log(value);
}
}
};
</script>
禁用選項(xiàng)

<el-cascader :options="options"></el-cascader>
<script>
export default {
data() {
return {
options: [{
value: 'zhinan',
label: '指南',
disabled: true,
children: [{
value: 'shejiyuanze',
label: '設(shè)計(jì)原則',
children: [{
value: 'yizhi',
label: '一致'
}, {
value: 'fankui',
label: '反饋'
}, {
value: 'xiaolv',
label: '效率'
}, {
value: 'kekong',
label: '可控'
}]
}, {
value: 'daohang',
label: '導(dǎo)航',
children: [{
value: 'cexiangdaohang',
label: '側(cè)向?qū)Ш?
}, {
value: 'dingbudaohang',
label: '頂部導(dǎo)航'
}]
}]
}, {
value: 'zujian',
label: '組件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}, {
value: 'color',
label: 'Color 色彩'
}, {
value: 'typography',
label: 'Typography 字體'
}, {
value: 'icon',
label: 'Icon 圖標(biāo)'
}, {
value: 'button',
label: 'Button 按鈕'
}]
}, {
value: 'form',
label: 'Form',
children: [{
value: 'radio',
label: 'Radio 單選框'
}, {
value: 'checkbox',
label: 'Checkbox 多選框'
}, {
value: 'input',
label: 'Input 輸入框'
}, {
value: 'input-number',
label: 'InputNumber 計(jì)數(shù)器'
}, {
value: 'select',
label: 'Select 選擇器'
}, {
value: 'cascader',
label: 'Cascader 級聯(lián)選擇器'
}, {
value: 'switch',
label: 'Switch 開關(guān)'
}, {
value: 'slider',
label: 'Slider 滑塊'
}, {
value: 'time-picker',
label: 'TimePicker 時(shí)間選擇器'
}, {
value: 'date-picker',
label: 'DatePicker 日期選擇器'
}, {
value: 'datetime-picker',
label: 'DateTimePicker 日期時(shí)間選擇器'
}, {
value: 'upload',
label: 'Upload 上傳'
}, {
value: 'rate',
label: 'Rate 評分'
}, {
value: 'form',
label: 'Form 表單'
}]
}, {
value: 'data',
label: 'Data',
children: [{
value: 'table',
label: 'Table 表格'
}, {
value: 'tag',
label: 'Tag 標(biāo)簽'
}, {
value: 'progress',
label: 'Progress 進(jìn)度條'
}, {
value: 'tree',
label: 'Tree 樹形控件'
}, {
value: 'pagination',
label: 'Pagination 分頁'
}, {
value: 'badge',
label: 'Badge 標(biāo)記'
}]
}, {
value: 'notice',
label: 'Notice',
children: [{
value: 'alert',
label: 'Alert 警告'
}, {
value: 'loading',
label: 'Loading 加載'
}, {
value: 'message',
label: 'Message 消息提示'
}, {
value: 'message-box',
label: 'MessageBox 彈框'
}, {
value: 'notification',
label: 'Notification 通知'
}]
}, {
value: 'navigation',
label: 'Navigation',
children: [{
value: 'menu',
label: 'NavMenu 導(dǎo)航菜單'
}, {
value: 'tabs',
label: 'Tabs 標(biāo)簽頁'
}, {
value: 'breadcrumb',
label: 'Breadcrumb 面包屑'
}, {
value: 'dropdown',
label: 'Dropdown 下拉菜單'
}, {
value: 'steps',
label: 'Steps 步驟條'
}]
}, {
value: 'others',
label: 'Others',
children: [{
value: 'dialog',
label: 'Dialog 對話框'
}, {
value: 'tooltip',
label: 'Tooltip 文字提示'
}, {
value: 'popover',
label: 'Popover 彈出框'
}, {
value: 'card',
label: 'Card 卡片'
}, {
value: 'carousel',
label: 'Carousel 走馬燈'
}, {
value: 'collapse',
label: 'Collapse 折疊面板'
}]
}]
}, {
value: 'ziyuan',
label: '資源',
children: [{
value: 'axure',
label: 'Axure Components'
}, {
value: 'sketch',
label: 'Sketch Templates'
}, {
value: 'jiaohu',
label: '組件交互文檔'
}]
}]
};
}
};
</script>
可清空

<el-cascader :options="options" clearable></el-cascader>
<script>
export default {
data() {
return {
options: [{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '設(shè)計(jì)原則',
children: [{
value: 'yizhi',
label: '一致'
}, {
value: 'fankui',
label: '反饋'
}, {
value: 'xiaolv',
label: '效率'
}, {
value: 'kekong',
label: '可控'
}]
}, {
value: 'daohang',
label: '導(dǎo)航',
children: [{
value: 'cexiangdaohang',
label: '側(cè)向?qū)Ш?
}, {
value: 'dingbudaohang',
label: '頂部導(dǎo)航'
}]
}]
}, {
value: 'zujian',
label: '組件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}, {
value: 'color',
label: 'Color 色彩'
}, {
value: 'typography',
label: 'Typography 字體'
}, {
value: 'icon',
label: 'Icon 圖標(biāo)'
}, {
value: 'button',
label: 'Button 按鈕'
}]
}, {
value: 'form',
label: 'Form',
children: [{
value: 'radio',
label: 'Radio 單選框'
}, {
value: 'checkbox',
label: 'Checkbox 多選框'
}, {
value: 'input',
label: 'Input 輸入框'
}, {
value: 'input-number',
label: 'InputNumber 計(jì)數(shù)器'
}, {
value: 'select',
label: 'Select 選擇器'
}, {
value: 'cascader',
label: 'Cascader 級聯(lián)選擇器'
}, {
value: 'switch',
label: 'Switch 開關(guān)'
}, {
value: 'slider',
label: 'Slider 滑塊'
}, {
value: 'time-picker',
label: 'TimePicker 時(shí)間選擇器'
}, {
value: 'date-picker',
label: 'DatePicker 日期選擇器'
}, {
value: 'datetime-picker',
label: 'DateTimePicker 日期時(shí)間選擇器'
}, {
value: 'upload',
label: 'Upload 上傳'
}, {
value: 'rate',
label: 'Rate 評分'
}, {
value: 'form',
label: 'Form 表單'
}]
}, {
value: 'data',
label: 'Data',
children: [{
value: 'table',
label: 'Table 表格'
}, {
value: 'tag',
label: 'Tag 標(biāo)簽'
}, {
value: 'progress',
label: 'Progress 進(jìn)度條'
}, {
value: 'tree',
label: 'Tree 樹形控件'
}, {
value: 'pagination',
label: 'Pagination 分頁'
}, {
value: 'badge',
label: 'Badge 標(biāo)記'
}]
}, {
value: 'notice',
label: 'Notice',
children: [{
value: 'alert',
label: 'Alert 警告'
}, {
value: 'loading',
label: 'Loading 加載'
}, {
value: 'message',
label: 'Message 消息提示'
}, {
value: 'message-box',
label: 'MessageBox 彈框'
}, {
value: 'notification',
label: 'Notification 通知'
}]
}, {
value: 'navigation',
label: 'Navigation',
children: [{
value: 'menu',
label: 'NavMenu 導(dǎo)航菜單'
}, {
value: 'tabs',
label: 'Tabs 標(biāo)簽頁'
}, {
value: 'breadcrumb',
label: 'Breadcrumb 面包屑'
}, {
value: 'dropdown',
label: 'Dropdown 下拉菜單'
}, {
value: 'steps',
label: 'Steps 步驟條'
}]
}, {
value: 'others',
label: 'Others',
children: [{
value: 'dialog',
label: 'Dialog 對話框'
}, {
value: 'tooltip',
label: 'Tooltip 文字提示'
}, {
value: 'popover',
label: 'Popover 彈出框'
}, {
value: 'card',
label: 'Card 卡片'
}, {
value: 'carousel',
label: 'Carousel 走馬燈'
}, {
value: 'collapse',
label: 'Collapse 折疊面板'
}]
}]
}, {
value: 'ziyuan',
label: '資源',
children: [{
value: 'axure',
label: 'Axure Components'
}, {
value: 'sketch',
label: 'Sketch Templates'
}, {
value: 'jiaohu',
label: '組件交互文檔'
}]
}]
}
}
}
</script>
僅顯示最后一級

<el-cascader :options="options" :show-all-levels="false"></el-cascader>
<script>
export default {
data() {
return {
options: [{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '設(shè)計(jì)原則',
children: [{
value: 'yizhi',
label: '一致'
}, {
value: 'fankui',
label: '反饋'
}, {
value: 'xiaolv',
label: '效率'
}, {
value: 'kekong',
label: '可控'
}]
}, {
value: 'daohang',
label: '導(dǎo)航',
children: [{
value: 'cexiangdaohang',
label: '側(cè)向?qū)Ш?
}, {
value: 'dingbudaohang',
label: '頂部導(dǎo)航'
}]
}]
}, {
value: 'zujian',
label: '組件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}, {
value: 'color',
label: 'Color 色彩'
}, {
value: 'typography',
label: 'Typography 字體'
}, {
value: 'icon',
label: 'Icon 圖標(biāo)'
}, {
value: 'button',
label: 'Button 按鈕'
}]
}, {
value: 'form',
label: 'Form',
children: [{
value: 'radio',
label: 'Radio 單選框'
}, {
value: 'checkbox',
label: 'Checkbox 多選框'
}, {
value: 'input',
label: 'Input 輸入框'
}, {
value: 'input-number',
label: 'InputNumber 計(jì)數(shù)器'
}, {
value: 'select',
label: 'Select 選擇器'
}, {
value: 'cascader',
label: 'Cascader 級聯(lián)選擇器'
}, {
value: 'switch',
label: 'Switch 開關(guān)'
}, {
value: 'slider',
label: 'Slider 滑塊'
}, {
value: 'time-picker',
label: 'TimePicker 時(shí)間選擇器'
}, {
value: 'date-picker',
label: 'DatePicker 日期選擇器'
}, {
value: 'datetime-picker',
label: 'DateTimePicker 日期時(shí)間選擇器'
}, {
value: 'upload',
label: 'Upload 上傳'
}, {
value: 'rate',
label: 'Rate 評分'
}, {
value: 'form',
label: 'Form 表單'
}]
}, {
value: 'data',
label: 'Data',
children: [{
value: 'table',
label: 'Table 表格'
}, {
value: 'tag',
label: 'Tag 標(biāo)簽'
}, {
value: 'progress',
label: 'Progress 進(jìn)度條'
}, {
value: 'tree',
label: 'Tree 樹形控件'
}, {
value: 'pagination',
label: 'Pagination 分頁'
}, {
value: 'badge',
label: 'Badge 標(biāo)記'
}]
}, {
value: 'notice',
label: 'Notice',
children: [{
value: 'alert',
label: 'Alert 警告'
}, {
value: 'loading',
label: 'Loading 加載'
}, {
value: 'message',
label: 'Message 消息提示'
}, {
value: 'message-box',
label: 'MessageBox 彈框'
}, {
value: 'notification',
label: 'Notification 通知'
}]
}, {
value: 'navigation',
label: 'Navigation',
children: [{
value: 'menu',
label: 'NavMenu 導(dǎo)航菜單'
}, {
value: 'tabs',
label: 'Tabs 標(biāo)簽頁'
}, {
value: 'breadcrumb',
label: 'Breadcrumb 面包屑'
}, {
value: 'dropdown',
label: 'Dropdown 下拉菜單'
}, {
value: 'steps',
label: 'Steps 步驟條'
}]
}, {
value: 'others',
label: 'Others',
children: [{
value: 'dialog',
label: 'Dialog 對話框'
}, {
value: 'tooltip',
label: 'Tooltip 文字提示'
}, {
value: 'popover',
label: 'Popover 彈出框'
}, {
value: 'card',
label: 'Card 卡片'
}, {
value: 'carousel',
label: 'Carousel 走馬燈'
}, {
value: 'collapse',
label: 'Collapse 折疊面板'
}]
}]
}, {
value: 'ziyuan',
label: '資源',
children: [{
value: 'axure',
label: 'Axure Components'
}, {
value: 'sketch',
label: 'Sketch Templates'
}, {
value: 'jiaohu',
label: '組件交互文檔'
}]
}]
};
}
};
</script>
多選

<div class="block">
<span class="demonstration">默認(rèn)顯示所有Tag</span>
<el-cascader
:options="options"
:props="props"
clearable></el-cascader>
</div>
<div class="block">
<span class="demonstration">折疊展示Tag</span>
<el-cascader
:options="options"
:props="props"
collapse-tags
clearable></el-cascader>
</div>
<script>
export default {
data() {
return {
props: { multiple: true },
options: [{
value: 1,
label: '東南',
children: [{
value: 2,
label: '上海',
children: [
{ value: 3, label: '普陀' },
{ value: 4, label: '黃埔' },
{ value: 5, label: '徐匯' }
]
}, {
value: 7,
label: '江蘇',
children: [
{ value: 8, label: '南京' },
{ value: 9, label: '蘇州' },
{ value: 10, label: '無錫' }
]
}, {
value: 12,
label: '浙江',
children: [
{ value: 13, label: '杭州' },
{ value: 14, label: '寧波' },
{ value: 15, label: '嘉興' }
]
}]
}, {
value: 17,
label: '西北',
children: [{
value: 18,
label: '陜西',
children: [
{ value: 19, label: '西安' },
{ value: 20, label: '延安' }
]
}, {
value: 21,
label: '新疆維吾爾族自治區(qū)',
children: [
{ value: 22, label: '烏魯木齊' },
{ value: 23, label: '克拉瑪依' }
]
}]
}]
};
}
};
</script>
選擇任意一級選項(xiàng)

<div class="block">
<span class="demonstration">單選選擇任意一級選項(xiàng)</span>
<el-cascader
:options="options"
:props="{ checkStrictly: true }"
clearable></el-cascader>
</div>
<div class="block">
<span class="demonstration">多選選擇任意一級選項(xiàng)</span>
<el-cascader
:options="options"
:props="{ multiple: true, checkStrictly: true }"
clearable></el-cascader>
</div>
<script>
export default {
data() {
return {
options: [{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '設(shè)計(jì)原則',
children: [{
value: 'yizhi',
label: '一致'
}, {
value: 'fankui',
label: '反饋'
}, {
value: 'xiaolv',
label: '效率'
}, {
value: 'kekong',
label: '可控'
}]
}, {
value: 'daohang',
label: '導(dǎo)航',
children: [{
value: 'cexiangdaohang',
label: '側(cè)向?qū)Ш?
}, {
value: 'dingbudaohang',
label: '頂部導(dǎo)航'
}]
}]
}, {
value: 'zujian',
label: '組件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}, {
value: 'color',
label: 'Color 色彩'
}, {
value: 'typography',
label: 'Typography 字體'
}, {
value: 'icon',
label: 'Icon 圖標(biāo)'
}, {
value: 'button',
label: 'Button 按鈕'
}]
}, {
value: 'form',
label: 'Form',
children: [{
value: 'radio',
label: 'Radio 單選框'
}, {
value: 'checkbox',
label: 'Checkbox 多選框'
}, {
value: 'input',
label: 'Input 輸入框'
}, {
value: 'input-number',
label: 'InputNumber 計(jì)數(shù)器'
}, {
value: 'select',
label: 'Select 選擇器'
}, {
value: 'cascader',
label: 'Cascader 級聯(lián)選擇器'
}, {
value: 'switch',
label: 'Switch 開關(guān)'
}, {
value: 'slider',
label: 'Slider 滑塊'
}, {
value: 'time-picker',
label: 'TimePicker 時(shí)間選擇器'
}, {
value: 'date-picker',
label: 'DatePicker 日期選擇器'
}, {
value: 'datetime-picker',
label: 'DateTimePicker 日期時(shí)間選擇器'
}, {
value: 'upload',
label: 'Upload 上傳'
}, {
value: 'rate',
label: 'Rate 評分'
}, {
value: 'form',
label: 'Form 表單'
}]
}, {
value: 'data',
label: 'Data',
children: [{
value: 'table',
label: 'Table 表格'
}, {
value: 'tag',
label: 'Tag 標(biāo)簽'
}, {
value: 'progress',
label: 'Progress 進(jìn)度條'
}, {
value: 'tree',
label: 'Tree 樹形控件'
}, {
value: 'pagination',
label: 'Pagination 分頁'
}, {
value: 'badge',
label: 'Badge 標(biāo)記'
}]
}, {
value: 'notice',
label: 'Notice',
children: [{
value: 'alert',
label: 'Alert 警告'
}, {
value: 'loading',
label: 'Loading 加載'
}, {
value: 'message',
label: 'Message 消息提示'
}, {
value: 'message-box',
label: 'MessageBox 彈框'
}, {
value: 'notification',
label: 'Notification 通知'
}]
}, {
value: 'navigation',
label: 'Navigation',
children: [{
value: 'menu',
label: 'NavMenu 導(dǎo)航菜單'
}, {
value: 'tabs',
label: 'Tabs 標(biāo)簽頁'
}, {
value: 'breadcrumb',
label: 'Breadcrumb 面包屑'
}, {
value: 'dropdown',
label: 'Dropdown 下拉菜單'
}, {
value: 'steps',
label: 'Steps 步驟條'
}]
}, {
value: 'others',
label: 'Others',
children: [{
value: 'dialog',
label: 'Dialog 對話框'
}, {
value: 'tooltip',
label: 'Tooltip 文字提示'
}, {
value: 'popover',
label: 'Popover 彈出框'
}, {
value: 'card',
label: 'Card 卡片'
}, {
value: 'carousel',
label: 'Carousel 走馬燈'
}, {
value: 'collapse',
label: 'Collapse 折疊面板'
}]
}]
}, {
value: 'ziyuan',
label: '資源',
children: [{
value: 'axure',
label: 'Axure Components'
}, {
value: 'sketch',
label: 'Sketch Templates'
}, {
value: 'jiaohu',
label: '組件交互文檔'
}]
}]
};
}
};
</script>
動(dòng)態(tài)加載

<el-cascader :props="props"></el-cascader>
<script>
let id = 0;
export default {
data() {
return {
props: {
lazy: true,
lazyLoad (node, resolve) {
const { level } = node;
setTimeout(() => {
const nodes = Array.from({ length: level + 1 })
.map(item => ({
value: ++id,
label: `選項(xiàng)${id}`,
leaf: level >= 2
}));
// 通過調(diào)用resolve將子節(jié)點(diǎn)數(shù)據(jù)返回,通知組件數(shù)據(jù)加載完成
resolve(nodes);
}, 1000);
}
}
};
}
};
可搜索

<div class="block">
<span class="demonstration">單選可搜索</span>
<el-cascader
placeholder="試試搜索:指南"
:options="options"
filterable></el-cascader>
</div>
<div class="block">
<span class="demonstration">多選可搜索</span>
<el-cascader
placeholder="試試搜索:指南"
:options="options"
:props="{ multiple: true }"
filterable></el-cascader>
</div>
<script>
export default {
data() {
return {
options: [{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '設(shè)計(jì)原則',
children: [{
value: 'yizhi',
label: '一致'
}, {
value: 'fankui',
label: '反饋'
}, {
value: 'xiaolv',
label: '效率'
}, {
value: 'kekong',
label: '可控'
}]
}, {
value: 'daohang',
label: '導(dǎo)航',
children: [{
value: 'cexiangdaohang',
label: '側(cè)向?qū)Ш?
}, {
value: 'dingbudaohang',
label: '頂部導(dǎo)航'
}]
}]
}, {
value: 'zujian',
label: '組件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}, {
value: 'color',
label: 'Color 色彩'
}, {
value: 'typography',
label: 'Typography 字體'
}, {
value: 'icon',
label: 'Icon 圖標(biāo)'
}, {
value: 'button',
label: 'Button 按鈕'
}]
}, {
value: 'form',
label: 'Form',
children: [{
value: 'radio',
label: 'Radio 單選框'
}, {
value: 'checkbox',
label: 'Checkbox 多選框'
}, {
value: 'input',
label: 'Input 輸入框'
}, {
value: 'input-number',
label: 'InputNumber 計(jì)數(shù)器'
}, {
value: 'select',
label: 'Select 選擇器'
}, {
value: 'cascader',
label: 'Cascader 級聯(lián)選擇器'
}, {
value: 'switch',
label: 'Switch 開關(guān)'
}, {
value: 'slider',
label: 'Slider 滑塊'
}, {
value: 'time-picker',
label: 'TimePicker 時(shí)間選擇器'
}, {
value: 'date-picker',
label: 'DatePicker 日期選擇器'
}, {
value: 'datetime-picker',
label: 'DateTimePicker 日期時(shí)間選擇器'
}, {
value: 'upload',
label: 'Upload 上傳'
}, {
value: 'rate',
label: 'Rate 評分'
}, {
value: 'form',
label: 'Form 表單'
}]
}, {
value: 'data',
label: 'Data',
children: [{
value: 'table',
label: 'Table 表格'
}, {
value: 'tag',
label: 'Tag 標(biāo)簽'
}, {
value: 'progress',
label: 'Progress 進(jìn)度條'
}, {
value: 'tree',
label: 'Tree 樹形控件'
}, {
value: 'pagination',
label: 'Pagination 分頁'
}, {
value: 'badge',
label: 'Badge 標(biāo)記'
}]
}, {
value: 'notice',
label: 'Notice',
children: [{
value: 'alert',
label: 'Alert 警告'
}, {
value: 'loading',
label: 'Loading 加載'
}, {
value: 'message',
label: 'Message 消息提示'
}, {
value: 'message-box',
label: 'MessageBox 彈框'
}, {
value: 'notification',
label: 'Notification 通知'
}]
}, {
value: 'navigation',
label: 'Navigation',
children: [{
value: 'menu',
label: 'NavMenu 導(dǎo)航菜單'
}, {
value: 'tabs',
label: 'Tabs 標(biāo)簽頁'
}, {
value: 'breadcrumb',
label: 'Breadcrumb 面包屑'
}, {
value: 'dropdown',
label: 'Dropdown 下拉菜單'
}, {
value: 'steps',
label: 'Steps 步驟條'
}]
}, {
value: 'others',
label: 'Others',
children: [{
value: 'dialog',
label: 'Dialog 對話框'
}, {
value: 'tooltip',
label: 'Tooltip 文字提示'
}, {
value: 'popover',
label: 'Popover 彈出框'
}, {
value: 'card',
label: 'Card 卡片'
}, {
value: 'carousel',
label: 'Carousel 走馬燈'
}, {
value: 'collapse',
label: 'Collapse 折疊面板'
}]
}]
}, {
value: 'ziyuan',
label: '資源',
children: [{
value: 'axure',
label: 'Axure Components'
}, {
value: 'sketch',
label: 'Sketch Templates'
}, {
value: 'jiaohu',
label: '組件交互文檔'
}]
}]
};
}
};
</script>
自定義節(jié)點(diǎn)內(nèi)容

<el-cascader :options="options">
<template slot-scope="{ node, data }">
<span>{{ data.label }}</span>
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
</template>
</el-cascader>
<script>
export default {
data() {
return {
options: [{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '設(shè)計(jì)原則',
children: [{
value: 'yizhi',
label: '一致'
}, {
value: 'fankui',
label: '反饋'
}, {
value: 'xiaolv',
label: '效率'
}, {
value: 'kekong',
label: '可控'
}]
}, {
value: 'daohang',
label: '導(dǎo)航',
children: [{
value: 'cexiangdaohang',
label: '側(cè)向?qū)Ш?
}, {
value: 'dingbudaohang',
label: '頂部導(dǎo)航'
}]
}]
}, {
value: 'zujian',
label: '組件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}, {
value: 'color',
label: 'Color 色彩'
}, {
value: 'typography',
label: 'Typography 字體'
}, {
value: 'icon',
label: 'Icon 圖標(biāo)'
}, {
value: 'button',
label: 'Button 按鈕'
}]
}, {
value: 'form',
label: 'Form',
children: [{
value: 'radio',
label: 'Radio 單選框'
}, {
value: 'checkbox',
label: 'Checkbox 多選框'
}, {
value: 'input',
label: 'Input 輸入框'
}, {
value: 'input-number',
label: 'InputNumber 計(jì)數(shù)器'
}, {
value: 'select',
label: 'Select 選擇器'
}, {
value: 'cascader',
label: 'Cascader 級聯(lián)選擇器'
}, {
value: 'switch',
label: 'Switch 開關(guān)'
}, {
value: 'slider',
label: 'Slider 滑塊'
}, {
value: 'time-picker',
label: 'TimePicker 時(shí)間選擇器'
}, {
value: 'date-picker',
label: 'DatePicker 日期選擇器'
}, {
value: 'datetime-picker',
label: 'DateTimePicker 日期時(shí)間選擇器'
}, {
value: 'upload',
label: 'Upload 上傳'
}, {
value: 'rate',
label: 'Rate 評分'
}, {
value: 'form',
label: 'Form 表單'
}]
}, {
value: 'data',
label: 'Data',
children: [{
value: 'table',
label: 'Table 表格'
}, {
value: 'tag',
label: 'Tag 標(biāo)簽'
}, {
value: 'progress',
label: 'Progress 進(jìn)度條'
}, {
value: 'tree',
label: 'Tree 樹形控件'
}, {
value: 'pagination',
label: 'Pagination 分頁'
}, {
value: 'badge',
label: 'Badge 標(biāo)記'
}]
}, {
value: 'notice',
label: 'Notice',
children: [{
value: 'alert',
label: 'Alert 警告'
}, {
value: 'loading',
label: 'Loading 加載'
}, {
value: 'message',
label: 'Message 消息提示'
}, {
value: 'message-box',
label: 'MessageBox 彈框'
}, {
value: 'notification',
label: 'Notification 通知'
}]
}, {
value: 'navigation',
label: 'Navigation',
children: [{
value: 'menu',
label: 'NavMenu 導(dǎo)航菜單'
}, {
value: 'tabs',
label: 'Tabs 標(biāo)簽頁'
}, {
value: 'breadcrumb',
label: 'Breadcrumb 面包屑'
}, {
value: 'dropdown',
label: 'Dropdown 下拉菜單'
}, {
value: 'steps',
label: 'Steps 步驟條'
}]
}, {
value: 'others',
label: 'Others',
children: [{
value: 'dialog',
label: 'Dialog 對話框'
}, {
value: 'tooltip',
label: 'Tooltip 文字提示'
}, {
value: 'popover',
label: 'Popover 彈出框'
}, {
value: 'card',
label: 'Card 卡片'
}, {
value: 'carousel',
label: 'Carousel 走馬燈'
}, {
value: 'collapse',
label: 'Collapse 折疊面板'
}]
}]
}, {
value: 'ziyuan',
label: '資源',
children: [{
value: 'axure',
label: 'Axure Components'
}, {
value: 'sketch',
label: 'Sketch Templates'
}, {
value: 'jiaohu',
label: '組件交互文檔'
}]
}]
}
}
}
</script>
級聯(lián)面板

<el-cascader-panel :options="options"></el-cascader-panel>
<script>
export default {
data() {
return {
options: [{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '設(shè)計(jì)原則',
children: [{
value: 'yizhi',
label: '一致'
}, {
value: 'fankui',
label: '反饋'
}, {
value: 'xiaolv',
label: '效率'
}, {
value: 'kekong',
label: '可控'
}]
}, {
value: 'daohang',
label: '導(dǎo)航',
children: [{
value: 'cexiangdaohang',
label: '側(cè)向?qū)Ш?
}, {
value: 'dingbudaohang',
label: '頂部導(dǎo)航'
}]
}]
}, {
value: 'zujian',
label: '組件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}, {
value: 'color',
label: 'Color 色彩'
}, {
value: 'typography',
label: 'Typography 字體'
}, {
value: 'icon',
label: 'Icon 圖標(biāo)'
}, {
value: 'button',
label: 'Button 按鈕'
}]
}, {
value: 'form',
label: 'Form',
children: [{
value: 'radio',
label: 'Radio 單選框'
}, {
value: 'checkbox',
label: 'Checkbox 多選框'
}, {
value: 'input',
label: 'Input 輸入框'
}, {
value: 'input-number',
label: 'InputNumber 計(jì)數(shù)器'
}, {
value: 'select',
label: 'Select 選擇器'
}, {
value: 'cascader',
label: 'Cascader 級聯(lián)選擇器'
}, {
value: 'switch',
label: 'Switch 開關(guān)'
}, {
value: 'slider',
label: 'Slider 滑塊'
}, {
value: 'time-picker',
label: 'TimePicker 時(shí)間選擇器'
}, {
value: 'date-picker',
label: 'DatePicker 日期選擇器'
}, {
value: 'datetime-picker',
label: 'DateTimePicker 日期時(shí)間選擇器'
}, {
value: 'upload',
label: 'Upload 上傳'
}, {
value: 'rate',
label: 'Rate 評分'
}, {
value: 'form',
label: 'Form 表單'
}]
}, {
value: 'data',
label: 'Data',
children: [{
value: 'table',
label: 'Table 表格'
}, {
value: 'tag',
label: 'Tag 標(biāo)簽'
}, {
value: 'progress',
label: 'Progress 進(jìn)度條'
}, {
value: 'tree',
label: 'Tree 樹形控件'
}, {
value: 'pagination',
label: 'Pagination 分頁'
}, {
value: 'badge',
label: 'Badge 標(biāo)記'
}]
}, {
value: 'notice',
label: 'Notice',
children: [{
value: 'alert',
label: 'Alert 警告'
}, {
value: 'loading',
label: 'Loading 加載'
}, {
value: 'message',
label: 'Message 消息提示'
}, {
value: 'message-box',
label: 'MessageBox 彈框'
}, {
value: 'notification',
label: 'Notification 通知'
}]
}, {
value: 'navigation',
label: 'Navigation',
children: [{
value: 'menu',
label: 'NavMenu 導(dǎo)航菜單'
}, {
value: 'tabs',
label: 'Tabs 標(biāo)簽頁'
}, {
value: 'breadcrumb',
label: 'Breadcrumb 面包屑'
}, {
value: 'dropdown',
label: 'Dropdown 下拉菜單'
}, {
value: 'steps',
label: 'Steps 步驟條'
}]
}, {
value: 'others',
label: 'Others',
children: [{
value: 'dialog',
label: 'Dialog 對話框'
}, {
value: 'tooltip',
label: 'Tooltip 文字提示'
}, {
value: 'popover',
label: 'Popover 彈出框'
}, {
value: 'card',
label: 'Card 卡片'
}, {
value: 'carousel',
label: 'Carousel 走馬燈'
}, {
value: 'collapse',
label: 'Collapse 折疊面板'
}]
}]
}, {
value: 'ziyuan',
label: '資源',
children: [{
value: 'axure',
label: 'Axure Components'
}, {
value: 'sketch',
label: 'Sketch Templates'
}, {
value: 'jiaohu',
label: '組件交互文檔'
}]
}]
};
}
};
</script>
Cascader Attributes


Cascader Events

Cascader Slots

CascaderPanel Attributes

CascaderPanel Events

CascaderPanel Slots

Props


到此這篇關(guān)于Element Cascader 級聯(lián)選擇器的使用示例的文章就介紹到這了,更多相關(guān)Element Cascader 級聯(lián)選擇器內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
elementUI下拉框?qū)崿F(xiàn)隱藏時(shí)觸發(fā)相關(guān)事件方式
這篇文章主要介紹了elementUI下拉框?qū)崿F(xiàn)隱藏時(shí)觸發(fā)相關(guān)事件方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10
vue各種事件監(jiān)聽實(shí)例(小結(jié))
這篇文章主要介紹了vue各種事件監(jiān)聽實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06
關(guān)于Element-ui中Table表格無法顯示的問題及解決
這篇文章主要介紹了關(guān)于Element-ui中Table表格無法顯示的問題及解決方案,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08
Vue項(xiàng)目導(dǎo)入導(dǎo)出文件功能以及導(dǎo)出文件后亂碼問題及解決
這篇文章主要介紹了Vue項(xiàng)目導(dǎo)入導(dǎo)出文件功能以及導(dǎo)出文件后亂碼問題及解決方案,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09
使用vue3+ts+setup獲取全局變量getCurrentInstance的方法實(shí)例
這篇文章主要給大家介紹了關(guān)于使用vue3+ts+setup獲取全局變量getCurrentInstance的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用vue3具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2022-08-08
vue 組件 全局注冊和局部注冊的實(shí)現(xiàn)
下面小編就為大家分享一篇vue 組件 全局注冊和局部注冊的實(shí)現(xiàn),具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-02-02

