Skip to content

Select 选择器

在清晰的选项列表中做出选择。

基础用法

已选:focus
查看 Vue 源码
Vue · TypeScript
<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

属性类型默认值说明
modelValuestringundefined通过 v-model 更新
labelstring必填可见标签
options{ label: string, value: string, disabled?: boolean }[]必填value 必须为非空且唯一的字符串
placeholderstring'请选择'未选择提示
disabledbooleanfalse禁止选择
namestringundefined表单字段名

事件

  • update:modelValue(string)

键盘操作与使用边界

Enter / Space 打开,方向键移动,Enter 选择,Escape 关闭;支持字符搜索。

安装

ts
import { AgmSelect } from 'augma'
import 'augma/style.css'