跳到正文Skip to content

下拉选择Select Menu SelectMenu

自绘 listbox 取代原生 <select>;键盘/翻转/先设宽再测量Custom listbox replacing native <select>; keyboard, flip, measure-then-position

表单Form Vue 组件Vue component

实时示例Live example

活体样例,可直接交互(点开浮层 / 下拉 / 试试键盘)——与组件画廊同源,切主题会同步。Interactive sample straight from the gallery (open overlays, dropdowns, try the keyboard); the theme stays in sync. 新标签打开 ↗Open in new tab ↗ · 看完整画廊Full gallery

PropsProps7

名称Name类型Type必填Required默认值Default说明Notes
modelValue string 否no ''
options FieldOption[] 否no () => []
id string 否no —
placeholder string 否no ''
disabled boolean 否no —
ariaLabel string 否no —
compact boolean 否no false

EventsEvents1

  • update:modelValue — v: string

Class 契约Class contract

照抄以下类名,不要自造——它们是本设计系统的唯一命名空间(anx- 前缀)。Copy these class names as-is — they are the system’s only namespace (anx- prefix).

anx-fsel anx-fsel--sm anx-fsel__btn anx-fsel__caret anx-fsel__check anx-fsel__opt anx-fsel__optlabel anx-fsel__panel anx-fsel__panel--sm anx-fsel__value anx-fsel__value--empty

无障碍Accessibility

  • 选中态用 aria-selected(同时是样式钩子)
  • 展开态用 aria-expanded
  • 弹层用 aria-controls 关联触发器
  • listbox 焦点管理用 aria-activedescendant
  • 自定义下拉用 listbox/option 语义

依赖Dependencies

Icon ui.types

源码Source

vue/ui/SelectMenu.vue 在 GitHub 上查看View on GitHub ↗