Element Cascader 級(jí)聯(lián)選擇器的使用示例
組件—級(jí)聯(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 級(jí)聯(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 評(píng)分' }, { 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 分頁(yè)' }, { 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)簽頁(yè)' }, { value: 'breadcrumb', label: 'Breadcrumb 面包屑' }, { value: 'dropdown', label: 'Dropdown 下拉菜單' }, { value: 'steps', label: 'Steps 步驟條' }] }, { value: 'others', label: 'Others', children: [{ value: 'dialog', label: 'Dialog 對(duì)話框' }, { 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 級(jí)聯(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 評(píng)分' }, { 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 分頁(yè)' }, { 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)簽頁(yè)' }, { value: 'breadcrumb', label: 'Breadcrumb 面包屑' }, { value: 'dropdown', label: 'Dropdown 下拉菜單' }, { value: 'steps', label: 'Steps 步驟條' }] }, { value: 'others', label: 'Others', children: [{ value: 'dialog', label: 'Dialog 對(duì)話框' }, { 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 級(jí)聯(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 評(píng)分' }, { 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 分頁(yè)' }, { 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)簽頁(yè)' }, { value: 'breadcrumb', label: 'Breadcrumb 面包屑' }, { value: 'dropdown', label: 'Dropdown 下拉菜單' }, { value: 'steps', label: 'Steps 步驟條' }] }, { value: 'others', label: 'Others', children: [{ value: 'dialog', label: 'Dialog 對(duì)話框' }, { 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>
僅顯示最后一級(jí)
<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 級(jí)聯(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 評(píng)分' }, { 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 分頁(yè)' }, { 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)簽頁(yè)' }, { value: 'breadcrumb', label: 'Breadcrumb 面包屑' }, { value: 'dropdown', label: 'Dropdown 下拉菜單' }, { value: 'steps', label: 'Steps 步驟條' }] }, { value: 'others', label: 'Others', children: [{ value: 'dialog', label: 'Dialog 對(duì)話框' }, { 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: '無(wú)錫' } ] }, { 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>
選擇任意一級(jí)選項(xiàng)
<div class="block"> <span class="demonstration">單選選擇任意一級(jí)選項(xiàng)</span> <el-cascader :options="options" :props="{ checkStrictly: true }" clearable></el-cascader> </div> <div class="block"> <span class="demonstration">多選選擇任意一級(jí)選項(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 級(jí)聯(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 評(píng)分' }, { 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 分頁(yè)' }, { 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)簽頁(yè)' }, { value: 'breadcrumb', label: 'Breadcrumb 面包屑' }, { value: 'dropdown', label: 'Dropdown 下拉菜單' }, { value: 'steps', label: 'Steps 步驟條' }] }, { value: 'others', label: 'Others', children: [{ value: 'dialog', label: 'Dialog 對(duì)話框' }, { 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 級(jí)聯(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 評(píng)分' }, { 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 分頁(yè)' }, { 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)簽頁(yè)' }, { value: 'breadcrumb', label: 'Breadcrumb 面包屑' }, { value: 'dropdown', label: 'Dropdown 下拉菜單' }, { value: 'steps', label: 'Steps 步驟條' }] }, { value: 'others', label: 'Others', children: [{ value: 'dialog', label: 'Dialog 對(duì)話框' }, { 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 級(jí)聯(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 評(píng)分' }, { 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 分頁(yè)' }, { 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)簽頁(yè)' }, { value: 'breadcrumb', label: 'Breadcrumb 面包屑' }, { value: 'dropdown', label: 'Dropdown 下拉菜單' }, { value: 'steps', label: 'Steps 步驟條' }] }, { value: 'others', label: 'Others', children: [{ value: 'dialog', label: 'Dialog 對(duì)話框' }, { 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>
級(jí)聯(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 級(jí)聯(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 評(píng)分' }, { 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 分頁(yè)' }, { 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)簽頁(yè)' }, { value: 'breadcrumb', label: 'Breadcrumb 面包屑' }, { value: 'dropdown', label: 'Dropdown 下拉菜單' }, { value: 'steps', label: 'Steps 步驟條' }] }, { value: 'others', label: 'Others', children: [{ value: 'dialog', label: 'Dialog 對(duì)話框' }, { 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 級(jí)聯(lián)選擇器的使用示例的文章就介紹到這了,更多相關(guān)Element Cascader 級(jí)聯(lián)選擇器內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue中判斷語(yǔ)句與循環(huán)語(yǔ)句基礎(chǔ)用法及v-if和v-for的注意事項(xiàng)詳解
在Vue指令中,最經(jīng)常被用于做邏輯操作的指令,下面這篇文章主要給大家介紹了關(guān)于Vue中判斷語(yǔ)句與循環(huán)語(yǔ)句基礎(chǔ)用法及v-if和v-for注意事項(xiàng)的相關(guān)資料,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下2022-08-08Vue?3?表格時(shí)間監(jiān)控與動(dòng)態(tài)后端請(qǐng)求觸發(fā)詳解?附Demo展示
在Vue3中,使用el-table組件渲染表格數(shù)據(jù),通過el-table-column指定內(nèi)容,時(shí)間點(diǎn)需前端校準(zhǔn),用getTime()比較,到達(dá)時(shí)觸發(fā)操作,異步API請(qǐng)求可用async/await處理,setInterval實(shí)現(xiàn)定時(shí)監(jiān)控,配合條件判斷防止重復(fù)請(qǐng)求2024-09-09Vue中關(guān)于computed計(jì)算屬性的妙用
這篇文章主要介紹了Vue中關(guān)于computed計(jì)算屬性的妙用,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-11-11VUE使用vue?create命令創(chuàng)建vue2.0項(xiàng)目的全過程
vue-cli是創(chuàng)建Vue項(xiàng)目的一個(gè)腳手架工具,vue-cli提供了vue create等命令,下面這篇文章主要給大家介紹了關(guān)于VUE使用vue?create命令創(chuàng)建vue2.0項(xiàng)目的相關(guān)資料,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下2022-07-07electron踩坑之remote of undefined的解決
這篇文章主要介紹了electron踩坑之remote of undefined的解決,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10Vue中的情侶屬性$dispatch和$broadcast詳解
這篇文章主要給大家介紹了關(guān)于Vue中情侶屬性$dispatch和$broadcast的相關(guān)資料,文中通過示例代碼以及圖文介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03利用vue+elementUI設(shè)置省市縣三級(jí)聯(lián)動(dòng)下拉列表框的詳細(xì)過程
在做電商項(xiàng)目的時(shí)候需要添加修改收貨地址,如何實(shí)現(xiàn)三級(jí)聯(lián)動(dòng)選取省市區(qū)地址困擾了我不少時(shí)間,這篇文章主要給大家介紹了關(guān)于利用vue+elementUI設(shè)置省市縣三級(jí)聯(lián)動(dòng)下拉列表框的相關(guān)資料,需要的朋友可以參考下2022-08-08