vue-devui Select 下拉选择框完整指南:从基础用法到远程搜索与源码原理
vue-devui Select 下拉选择框完整指南:从基础用法到远程搜索与源码原理
导读
本文以 vue-devui(基于全新 DevUI Design 设计体系的 Vue3 组件库)中 Select 下拉选择框组件文档 为核心,系统讲解 d-select 组件的基本用法、多选、禁用、可清空、分组、筛选与远程搜索、新增选项、远程加载数据等全部能力,并逐项对照 Select / Option / OptionGroup 的参数、事件、插槽与方法。同时结合 select 组件源码 与其核心 composable(如 use-select.ts、use-select-content.ts)以及 单元测试,揭示下拉面板渲染、筛选防抖、多选 tag 折叠、远程加载等功能的底层实现原理,帮助你在研发工具类项目中快速落地并深度定制。
组件概述与使用场景
d-select 是 vue-devui 中承担"数据录入"职责的下拉选择框组件(见 select/index.ts 的组件元信息)。它的核心定位是:
- 用户从多个选项中选择一项或几项;
- 仅支持用户在下拉选项中选择和搜索系统提供的选项,不支持自由输入(除非开启
allow-create新增选项能力)。
组件通过 select/index.ts 注册为全局组件 DSelect、DOption、DOptionGroup,三者配套使用:
app.component(Select.name, Select); // DSelect
app.component(Option.name, Option); // DOption
app.component(OptionGroup.name, OptionGroup); // DOptionGroup
基本用法:尺寸与外观
通过 size 设置 Select 大小,取值 sm、md(默认)、lg;通过 overview:underlined 设置只有下边框的样式(默认值为 border,即带完整边框)。
<template>
<div>
<div class="mb-0">Small</div>
<d-select class="mb-2" v-model="value1" :options="options" size="sm"></d-select>
<div class="mb-0">Middle</div>
<d-select class="mb-2" v-model="value2" :options="options"></d-select>
<div class="mb-0">Large</div>
<d-select class="mb-2" v-model="value3" :options="options" size="lg"></d-select>
<div class="mb-0">Underlined</div>
<d-select class="mb-2" v-model="value4" :options="options" size="lg" overview="underlined"></d-select>
</div>
</template>
<script>
import { defineComponent, reactive, ref } from 'vue';
export default defineComponent({
setup() {
const value1 = ref('');
const value2 = ref('');
const value3 = ref('');
const value4 = ref('');
const items = new Array(6).fill(0).map((item, i) => `Option ${i + 1}`);
const options = reactive(items);
return { value1, value2, value3, value4, options };
},
});
</script>
源码佐证:options 属性在 select-types.ts 中声明为 Array,支持纯字符串/数字数组,也支持对象数组({ name, value, ... })。在 use-select.ts 的 mergeOptions 中,组件会将原始 options 统一规整为内部选项对象:
- 普通字符串/数字:
name取字符串形式,value为原始值; - 对象类型:
name缺省时回退为value + ''; - 多选模式下会依据
modelValue计算_checked状态。
尺寸优先级在 use-select.ts 中体现为 props.size || formContext?.size || 'md',即组件自身 size 优先,其次继承父级 d-form 的 size,最后回退到 md。这一优先级在 select.spec.tsx 的 size priority 用例 中有完整的单测覆盖。样式方面,select.scss 中 --sm / --lg 分别调整字号与 tag 间距,--underlined 模式下选择框去掉边框、仅保留下边框(见 select.scss)。
多选与数量限制
通过 multiple:true 开启多选;通过 multiple-limit 限制可选数量(值为 0 表示不限制)。多选时还可配合 collapse-tags 将已选项折叠为数量显示,配合 collapse-tags-tooltip 在悬停折叠文字时展示具体所选值。
<template>
<div class="mb-0">基础多选</div>
<d-select class="mb-2" v-model="value1" :options="options" :multiple="true" :multiple-limit="2" />
<div class="mb-0">collapse-tags</div>
<d-select class="mb-2" v-model="value2" :options="options" :multiple="true" :collapse-tags="true" />
<div class="mb-0">collapse-tags-tooltip</div>
<d-select class="mb-2" v-model="value3" :options="options" :multiple="true" :collapse-tags="true" :collapse-tags-tooltip="true" />
</template>
<script>
import { defineComponent, reactive, ref } from 'vue';
export default defineComponent({
setup() {
const value1 = ref([]);
const value2 = ref([]);
const value3 = ref([]);
const items = new Array(6).fill(0).map((item, i) => `Option ${i + 1}`);
const options = reactive(items);
return { value1, value2, value3, options };
},
});
</script>
源码佐证:
- 多选时
d-select内部渲染Tag标签(见 select-content.tsx),每个 tag 可删除,删除触发tagDelete,进而更新modelValue并派发remove-tag事件(use-select.ts 的 tagDelete)。 collapse-tags开启后只保留第一个已选项的 tag,其余以+N折叠;再叠加collapse-tags-tooltip时,折叠的+N会包在Popover中,鼠标悬停即可查看并逐个删除剩余选中项。multiple-limit的判定逻辑在 use-select.ts 的 isDisabled:当已选数量达到上限且当前项未被选中时,未选中的项会被判定为禁用,从而阻止继续勾选。- 多选时下拉选项前会渲染
Checkbox复选框(见 select.tsx)。
禁用:整体禁用与单项禁用
通过 disabled:true 整体禁用 Select;通过 option-disabled-key 设置单个选项禁用。例如设置为 disabled,则对象上 disabled 为 true 时该选项不可选择;传入的资源为 Object 类型时该参数才会生效,传空串则不禁用任何选项。
<template>
<d-select class="mb-2" v-model="value1" :options="options1" :disabled="true" />
<d-select class="mb-2" v-model="value2" :options="options2" option-disabled-key="disabled" />
<d-select class="mb-2" v-model="value3" :options="options3" :multiple="true" option-disabled-key="notAllow" />
</template>
<script>
import { defineComponent, reactive, ref } from 'vue';
export default defineComponent({
setup() {
const value1 = ref('');
const value2 = ref('');
const value3 = ref([]);
const items = new Array(6).fill(0).map((item, i) => `Option ${i + 1}`);
const options1 = reactive(items);
const options2 = reactive([
{ name: 'Option 1', value: 0 },
{ name: 'Option 2', value: 1 },
{ name: 'Option 3', value: 2, disabled: true },
]);
const options3 = reactive([
{ name: 'Option 1', value: 0 },
{ name: 'Option 2', value: 1, notAllow: true },
{ name: 'Option 3', value: 2 },
]);
return { value1, value2, value3, options1, options2, options3 };
},
});
</script>
源码佐证:
- 整体禁用时,组件内部通过
formContext?.disabled || props.disabled计算selectDisabled(use-select.ts),也就是说 Select 也会继承所在d-form的禁用状态;toggleChange在禁用态下直接返回,点击不会展开下拉。 - 单项禁用通过
isDisabled(item)实现:optionDisabledKey非空时读取对象对应字段,字段值为true即禁用(use-select.ts 的 isDisabled)。 - 对应的禁用交互在 select.spec.tsx 的 select item disabled work 用例 中被验证:点击带
disabled: true的选项,modelValue不会变化。
可清空
通过 allow-clear:true 允许清空选值。注意:文档标注该配置仅单选场景适用,多选下清空按钮会将所有已选项一并清除(源码中 handleClear 对多选清空为 [],单选清空为 '',并触发 clear 事件)。
<template>
<d-select class="mb-2" v-model="value1" :options="options" :allow-clear="true" />
<d-select v-model="value2" :options="options" :multiple="true" :allow-clear="true" />
</template>
<script>
import { defineComponent, reactive, ref } from 'vue';
export default defineComponent({
setup() {
const value1 = ref('');
const value2 = ref([]);
const items = new Array(6).fill(0).map((item, i) => `Option ${i + 1}`);
const options = reactive(items);
return { value1, value2, options };
},
});
</script>
源码佐证:清空按钮(InputClearIcon)的显示受 mergeClearable 控制——组件未禁用、开启 allow-clear 且当前存在选值时才会显示(use-select-content.ts 的 mergeClearable)。样式上清空按钮默认隐藏,hover 选择框时替换掉下拉箭头(select.scss 的 clearable 规则)。clear 事件与清空行为在 select.spec.tsx 的 select clear work 用例 中得到验证。
下拉列表显隐:toggleChange 方法
通过暴露的 toggleChange 方法,可以在代码中控制下拉列表的展示和隐藏。组件通过 ctx.expose({ focus, blur, toggleChange }) 对外暴露这些方法(见 select.tsx),因此需要先给 d-select 绑定 ref。
<template>
<div>
<d-button @click.stop="toggleChange" @pointerup.stop="() => {}" class="mb-2">展开 / 隐藏</d-button>
<d-select ref="demoSelect" v-model="toggleValue" :options="options" @load-more="loadMore"></d-select>
</div>
</template>
<script>
import { defineComponent, reactive, ref } from 'vue';
export default defineComponent({
setup() {
const toggleValue = ref('');
const visitable = ref(false);
const items = new Array(12).fill(0).map((item, i) => `Option ${i + 1}`);
const options = reactive(items);
const newItems = new Array(2).fill(0).map((item, i) => `Option new`);
const demoSelect = ref(null);
const toggleChange = () => {
visitable.value = !visitable.value;
demoSelect.value.toggleChange(visitable.value);
};
const loadMore = () => {
if (options.length <= 20) {
options.push(...newItems);
console.log('load more');
}
};
return { toggleValue, options, demoSelect, toggleChange, loadMore };
},
});
</script>
源码佐证:toggleChange(bool) 内部会更新 isOpen 并同步派发 toggle-change 事件(use-select.ts)。此外组件基于 FlexibleOverlay(来自 overlay 组件)实现浮层定位,并通过 onClickOutside 监听外部点击自动收起下拉(use-select.ts)。注意 @toggleChange 事件名写法在模板中为 toggle-change,在 TSX/测试中为 onToggleChange。
自定义下拉面板:d-option 与 d-option-group
使用 d-option 自定义单个选项
通过 d-option 设置单个内容。value 为必填的选项唯一标识,name 为选项显示内容;当不传 name 时会回退显示 value。d-option 的默认插槽可以完全自定义选项内容和样式。
<template>
<div class="mb-0">d-option</div>
<d-select class="mb-2" v-model="value1" :allow-clear="true">
<d-option v-for="(item, index) in options.data" :key="index" :value="item.value" :name="item.name"></d-option>
</d-select>
<div class="mb-0">d-option自定义内容及样式</div>
<d-select class="mb-2" v-model="value2" :allow-clear="true">
<d-option v-for="(item, index) in options1.data" :key="index" :value="item">
<div class="clear-float">
<span style="float: left;">{{ item }}</span>
<span style="float: right;">{{ index + 1 }}</span>
</div>
</d-option>
</d-select>
</template>
<script>
import { defineComponent, reactive, ref } from 'vue';
export default defineComponent({
setup() {
const value1 = ref('');
const value2 = ref('');
const items = new Array(6).fill(0).map((item, i) => ({
value: `Option ${i + 1}`,
name: `Option ${i + 1}`,
}));
const items1 = new Array(6).fill(0).map((item, i) => `Option ${i + 1}`);
const options = reactive({ data: items });
const options1 = reactive({ data: items1 });
return { value1, value2, options, options1 };
},
});
</script>
<style>
.clear-float:after {
content: '';
display: block;
height: 0;
clear: both;
}
</style>
源码佐证:d-option 的实现位于 option.tsx,其核心逻辑在 use-option.ts:
- 通过
SELECT_TOKEN注入父级 Select 上下文,挂载时调用updateInjectOptions(optionItem, 'add', ...)把自身注册进选项集合,卸载时删除,从而支持动态增删选项(相关行为在 option.spec.tsx 的 option items data changed work 用例 中验证); - 默认插槽存在时优先渲染插槽内容,否则渲染
name || value; - 当
options属性和d-option子组件同时使用时二者互斥,文档明确"两者必须有且只有一个"。
使用 d-option-group 对选项分组
通过 d-option-group 将选项分组,其 label 属性为分组名,disabled 可整体禁用该分组下的所有选项。
<template>
<d-select v-model="groupValue" :allow-clear="true" class="select-option-group">
<d-option-group label="分组一">
<d-option v-for="(item, index) in options1.data" :key="index" :value="item.value" :name="item.name"></d-option>
</d-option-group>
<d-option-group label="分组二" :disabled="true">
<d-option v-for="(item, index) in options2.data" :key="index" :value="item.value" :name="item.name"></d-option>
</d-option-group>
</d-select>
</template>
<script>
import { defineComponent, reactive, ref } from 'vue';
export default defineComponent({
setup() {
const groupValue = ref('');
const items = new Array(6).fill(0).map((item, i) => ({
value: `Option ${i + 1}`,
name: `Option ${i + 1}`,
}));
const items1 = new Array(6).fill(0).map((item, i) => ({
value: `Test ${i + 1}`,
name: `Test ${i + 1}`,
}));
const options1 = reactive({ data: items });
const options2 = reactive({ data: items1 });
return { groupValue, options1, options2 };
},
});
</script>
<style>
.select-option-group {
ul {
padding: 0;
li {
list-style-type: none;
}
}
}
</style>
源码佐证:d-option-group 的实现位于 option-group.tsx,渲染为 select__group 结构(组标题 label + 组内容)。它通过 OPTION_GROUP_TOKEN 提供上下文;use-option.ts 中 isDisabled 会合并分组禁用状态(props.disabled || optionGroup?.disabled),因此组内所有选项都会变灰。分组渲染与分组禁用分别在 option-group.spec.tsx 的两个用例中验证。组间分隔线样式(&:not(:last-of-type)::after)定义于 select.scss。
筛选、搜索选项
添加 filter 属性开启筛选功能:
- 传入值为
true时,默认找出name属性包含输入值的选项(不区分大小写,按包含匹配); - 传入一个
Function时,输入值变化会调用该函数,参数为当前输入值,方便自定义过滤逻辑; - 添加
remote属性开启远程搜索,配合loading属性使用,加载时显示loading-text定义的文本。
<template>
<div class="mb-0">默认筛选</div>
<d-select class="mb-2" v-model="value1" :allow-clear="true" filter @input-change="handleInput">
<d-option v-for="(item, index) in options.data" :key="index" :value="item.value" :name="item.name"></d-option>
</d-select>
<div class="mb-0">远程搜索</div>
<d-select class="mb-2" v-model="value2" :allow-clear="true" :filter="filterFunc" remote placeholder="请输入搜索关键字" :loading="loading">
<d-option v-for="(item, index) in options1.data" :key="index" :value="item.value" :name="item.name"></d-option>
</d-select>
</template>
<script>
import { defineComponent, reactive, ref } from 'vue';
export default defineComponent({
setup() {
const value1 = ref('');
const value2 = ref('');
const loading = ref(false);
const items = new Array(6).fill(0).map((item, i) => ({
value: `Option ${i + 1}`,
name: `Option ${i + 1}`,
}));
const options = reactive({ data: items });
const options1 = reactive({ data: [] });
const filterFunc = (query) => {
if (query) {
loading.value = true;
setTimeout(() => {
options1.data = items.filter((item) => item.name.toLowerCase().includes(query.toLowerCase()));
loading.value = false;
}, 200);
} else {
options1.data = [];
}
};
const handleInput = (val) => {
console.log(val);
};
return { value1, value2, options, options1, loading, filterFunc, handleInput };
},
});
</script>
源码佐证:
- 默认筛选:
d-option的isVisible计算属性会把filterQuery转小写去空白后与name/value做包含匹配(use-option.ts),不匹配的选项通过v-show隐藏。 - 自定义过滤:
handlerQueryFunc检测isFunction(props.filter),是函数则直接调用props.filter(query),否则走内部queryChange(use-select.ts)。输入事件统一经debounceQueryFilter防抖,远程搜索(remote)的防抖时间为 300ms,本地筛选为 0(use-select.ts 的 debounceTime)。 - 远程搜索 + loading:
isLoading由loading布尔值驱动,加载态下下拉列表替换为loading-text文本;同时下拉容器套用dLoading指令(见 select.tsx)。 - 筛选相关交互在 select.spec.tsx 的 select filter work / select remote search work 用例 中被完整验证,包括"输入 s 时第一个选项隐藏、输入 1 时恢复显示"以及远程搜索加载中显示"加载中"。
新增选项:allow-create
添加 allow-create 属性开启新增选项功能。注意:为了让 allow-create 正常工作,filter 的值必须为 true(布尔值形式,而非函数)。
<template>
<d-select v-model="value" :options="options" :allow-clear="true" multiple filter allow-create> </d-select>
</template>
<script>
import { defineComponent, reactive, ref } from 'vue';
export default defineComponent({
setup() {
const value = ref([]);
const list = new Array(6).fill(0).map((item, i) => `Option ${i + 1}`);
const options = reactive(list);
return { value, options };
},
});
</script>
源码佐证:当 filter 为布尔 true 且 allowCreate 开启、输入框存在查询值、且当前没有任何选项与查询值同名时,组件会渲染一个 create 属性的特殊 d-option(见 select.tsx 中的 isShowCreateOption)。点击该选项后,valueChange 会把输入值写入 modelValue(多选时以数组追加),同时清空 filterQuery 并重新聚焦输入框(use-select.ts 的 valueChange)。对于多选场景,新增选项同样以 tag 形式回显。
远程加载数据
对于选项数据需要异步获取的场景,可以结合 @toggleChange 事件(下拉展开时触发)与 loading 属性完成首次远程拉取。
<template>
<d-select v-model="value" :options="options.data" :allow-clear="true" :loading="loading" @toggleChange="toggleChange"></d-select>
</template>
<script>
import { defineComponent, reactive, ref } from 'vue';
export default defineComponent({
setup() {
const value = ref([]);
const list = new Array(6).fill(0).map((item, i) => `Option ${i + 1}`);
const options = reactive({ data: [] });
const loading = ref(false);
const toggleChange = (bool) => {
if (bool) {
loading.value = true;
setTimeout(() => {
options.data = list;
loading.value = false;
}, 3000);
}
};
return { value, options, loading, toggleChange };
},
});
</script>
源码佐证:下拉容器监听 scroll 事件并在滚动到底部时触发 load-more(见 select.tsx 的 scrollToBottom),因此远程场景还支持滚动到底部分页加载。加载态文案默认来自组件内置国际化 loadingText(zh-CN 为"加载中..."),该行为在 select.spec.tsx 的 select remote loading work 用例 中被验证:下拉打开时显示加载文案,数据就绪后渲染 6 个选项。
API 参考:Select 参数
| 参数名 | 类型 | 默认 | 说明 |
|---|---|---|---|
| options | array |
[] |
可选,和使用 option 子组件互斥,两者必须有且只有一个 |
| multiple | boolean |
false |
可选,是否支持多选 |
| size | string |
'md' |
可选,下拉选框尺寸,有三种选择 'lg'、'md'、'sm';未设置时继承 d-form 的 size |
| disabled | boolean |
false |
可选,是否禁用下拉框 |
| placeholder | string |
'请选择' |
可选,输入框的 placeholder(默认值来自 locale,见 zh-cn.ts 的 select 文案) |
| overview | string |
'border' |
可选,决定选择框样式显示,默认有边框 'border'、'underlined' |
| option-disabled-key | string |
'' |
可选,禁用单个选项;当传入资源 options 类型为 Object,比如设置为 'disabled',则当对象的 disabled 属性为 true 时该选项将禁用;设置为 '' 时不禁用单个选项 |
| allow-clear | boolean |
false |
可选,配置是否允许清空选值,仅单选场景适用 |
| collapse-tags | boolean |
false |
可选,配置是否允许将所选项合并为数量显示 |
| collapse-tags-tooltip | boolean |
false |
可选,配置是否启用鼠标悬停折叠文字以显示具体所选值 |
| filter | boolean | function |
false |
可选,配置是否开启筛选功能;配置为函数时为自定义搜索过滤方法(参数为输入值) |
| remote | boolean |
false |
可选,配置是否启用远程搜索,配合 filter 函数使用 |
| allow-create | boolean |
false |
可选,配置是否启用新增选项,配合 filter 为 true 时使用 |
| no-data-text | string |
'无数据' |
可选,无选项时显示的文本,也可通过 empty 插槽自定义 |
| no-match-text | string |
'找不到相关记录' |
可选,搜索条件无匹配时显示的文本,也可通过 empty 插槽自定义 |
| loading | boolean |
false |
可选,配置下拉选项是否远程加载,配合 loading-text 使用 |
| loading-text | string |
'加载中' |
可选,远程搜索时显示的文本 |
| multiple-limit | number |
0 |
可选,multiple 为 true 时生效,表示最多可选项目数,为 0 则不限制 |
| show-glow-style | boolean |
true |
可选,是否展示悬浮发光效果(hover/open/focus 时 4px 光圈,见 select.scss 的 glow-style) |
| menu-class | string |
'' |
可选,自定义下拉菜单的样式名 |
| max-length | number |
-- |
可选,可筛选时输入框可输入的最大长度 |
| append-to-body | boolean |
true |
可选,下拉菜单是否 append to body(源码通过 Teleport to="body" disabled={!props.appendToBody} 实现,见 select.tsx) |
源码补充说明:以上参数在 select-types.ts 中有完整的 TypeScript 声明。其中 modelValue 支持 string | number | Array<number | string>;position 参数(文档未列但源码存在)支持 top/bottom/left/right 及其 -start/-end 变体,默认定位序列为 ['bottom', 'top', 'left', 'right']。
API 参考:Select 事件
| 事件名 | 类型 | 说明 |
|---|---|---|
| value-change | Function(data) |
可选,当选中值发生变化时触发,参数为目前选中的值(多选时为数组) |
| toggle-change | Function(boolean) |
可选,下拉打开关闭 toggle 事件 |
| focus | Function(e: FocusEvent) |
可选,获取焦点时触发 |
| blur | Function(e: FocusEvent) |
可选,失去焦点时触发 |
| clear | Function() |
可选,通过右侧删除图标清空所有选项时触发 |
| remove-tag | Function(value) |
可选,多选时删除单个 tag 时触发,参数为当前 tag 的值 |
| load-more | Function() |
可选,下拉框有滚动条时滚动到底部触发 |
| input-change | Function(value) |
可选,输入框输入内容时触发,参数为输入的值 |
源码补充说明:所有事件均在 select.tsx 的 emits 声明 中定义。toggle-change、focus、blur、value-change 的触发行为在 select.spec.tsx 的 select events work 用例 中被逐一断言(如点击展开触发一次 toggleChange、选中后触发一次 valueChange)。另外组件会在 modelValue 变化时调用所在 d-form-item 的 validate('change')(use-select.ts),因此可直接融入表单校验体系。
API 参考:Select 插槽与方法
插槽
| 名称 | 说明 |
|---|---|
| default | 自定义 Select 下拉面板内容(OptionGroup / Option) |
| empty | 自定义无选项时下拉面板内容 |
方法(通过组件 ref 调用)
| 名称 | 说明 |
|---|---|
| focus | 使选择器的输入框获取焦点 |
| blur | 使选择器的输入框失去焦点 |
| toggleChange | 使选择器的下拉列表显示/隐藏 |
源码补充说明:focus/blur 由 use-select-function.ts 实现,内部定位到 SelectContent 暴露的 input 原生输入框并调用其 focus()/blur();empty 插槽优先于内置的 no-data-text/no-match-text 文案渲染(见 select.tsx 的空态渲染分支)。
API 参考:OptionGroup 与 Option
OptionGroup 参数
| 参数名 | 类型 | 默认 | 说明 |
|---|---|---|---|
| label | string |
'' |
可选,分组的组名 |
| disabled | boolean |
false |
可选,是否禁用该分组下的所有选项 |
OptionGroup 插槽
| 名称 | 说明 |
|---|---|
| default | 自定义单个选项显示内容(Option) |
Option 参数
| 参数名 | 类型 | 默认 | 说明 |
|---|---|---|---|
| value | string | number |
'' |
必填,选项唯一标识 |
| name | string |
'' |
可选,选项显示内容 |
| disabled | boolean |
false |
可选,禁用单个选项 |
Option 插槽
| 名称 | 说明 |
|---|---|
| default | 自定义单个选项显示内容 |
源码补充说明:d-option 声明中还包含一个 create 内部属性(select-types.ts 的 optionProps),由组件内部在 allow-create 场景下自动注入,开发者无需关心。d-option-group 通过 OPTION_GROUP_TOKEN 与组内 d-option 通信(见 const.ts),实现"整组禁用"的联动。
补充实践建议
- options 与 d-option 二选一:简单静态列表优先使用
options属性;需要自定义选项内容(如双列布局、图标、富文本)时使用d-option默认插槽。 - 远程场景组合:首次进入用
@toggleChange+loading拉取初始数据;搜索用filter函数 +remote+loading;滚动分页用load-more。三者可以按需组合。 - 表单联动:Select 天然感知
d-form/d-form-item的 size、disabled 与校验状态(错误态下选择框边框变红,见 use-select-content.ts 的 isValidateError 与 select.scss 的 selection--error),推荐在表单场景中直接组合使用。 - 样式定制:下拉菜单最大高度为 300px(select.scss 的 $select-dropdown-max-height),若选项很多建议配合
load-more分页;可通过menu-class覆盖下拉菜单样式,通过show-glow-style关闭悬浮发光效果。
以上内容全部以 Select 下拉选择框文档 为骨架,并结合仓库内 select 源码目录 与 select 测试目录 中的实现细节展开,可作为你在 vue-devui 中接入和定制下拉选择框的完整参考。