Select 选择器
在清晰的选项列表中做出选择。
基础用法
查看 Vue 源码
<script setup lang="ts">
import { AgmSelect } from 'augma'
import { shallowRef } from 'vue'
const mode = shallowRef('focus')
const options = [
{ label: '专注模式', value: 'focus' },
{ label: '探索模式', value: 'explore' },
{ label: '不可用模式', value: 'locked', disabled: true },
]
</script>
<template>
<div class="example-stack">
<AgmSelect v-model="mode" label="显示模式" :options="options" />
<output>已选:{{ mode }}</output>
<AgmSelect label="不可用选择器" :options="options" disabled />
</div>
</template>
<style scoped>
.example-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
}
.example-stack {
display: grid;
gap: 24px;
width: 100%;
max-width: 360px;
}
</style>
API
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
modelValue | string | undefined | 通过 v-model 更新 |
label | string | 必填 | 可见标签 |
options | { label: string, value: string, disabled?: boolean }[] | 必填 | value 必须为非空且唯一的字符串 |
placeholder | string | '请选择' | 未选择提示 |
disabled | boolean | false | 禁止选择 |
name | string | undefined | 表单字段名 |
事件
update:modelValue(string)
键盘操作与使用边界
Enter / Space 打开,方向键移动,Enter 选择,Escape 关闭;支持字符搜索。
安装
ts
import { AgmSelect } from 'augma'
import 'augma/style.css'