Skip to content

Select 选择器

赛博风格下拉选择器,支持单选、多选、搜索、禁用、分组选项、自定义字段名和不同主题。

基础用法

vue
<template>
  <cyber-select v-model="value" :options="options" placeholder="请选择" />
</template>

<script setup>
import { ref } from 'vue'

const value = ref('')
const options = [
  { label: '选项 1', value: 'option1' },
  { label: '选项 2', value: 'option2' },
  { label: '选项 3', value: 'option3' },
]
</script>

可搜索

vue
<template>
  <cyber-select v-model="searchValue" :options="longOptions" filterable />
</template>

多选

vue
<template>
  <cyber-select v-model="multiValue" :options="options" multiple />
</template>

主题







vue
<template>
  <cyber-select theme="neon" :options="options" />
  <cyber-select theme="terminal" :options="options" />
  <cyber-select theme="matrix" :options="options" />
  <cyber-select theme="hologram" :options="options" />
</template>

分组选项

vue
<template>
  <cyber-select v-model="groupValue" :options="groupOptions" />
</template>

<script setup>
import { ref } from 'vue'

const groupValue = ref('')
const groupOptions = [
  {
    label: '前端技术',
    options: [
      { label: 'Vue.js', value: 'vue' },
      { label: 'React', value: 'react' },
    ],
  },
  {
    label: '后端技术',
    options: [
      { label: 'Node.js', value: 'node' },
      { label: 'Python', value: 'python' },
    ],
  },
]
</script>

自定义字段

vue
<template>
  <cyber-select
    v-model="customValue"
    :options="customOptions"
    label-key="name"
    value-key="id"
  />
</template>

事件

vue
<template>
  <cyber-select
    v-model="value"
    :options="options"
    @change="handleChange"
    @focus="handleFocus"
    @blur="handleBlur"
  />
</template>

参数说明

名称说明类型可选值默认值
modelValue / v-model当前选中值string | number | boolean | null | Array-''
options选项列表,支持分组Array-[]
placeholder占位文字string-请选择
searchPlaceholder搜索框占位文字string-搜索选项
noDataText空状态文字string-暂无数据
disabled是否禁用boolean-false
clearable是否可清空boolean-true
filterable是否可搜索boolean-false
multiple是否多选boolean-false
size尺寸stringlarge / default / smalldefault
theme主题stringneon / terminal / matrix / hologramneon
labelKey选项标签字段string-label
valueKey选项值字段string-value

事件说明

名称说明回调参数
change选中值变化时触发(value, option)
focus获得焦点时触发(event)
blur失去焦点时触发(event)
visible-change下拉显示状态变化时触发(visible)
clear清空选中值时触发-

选项数据结构

基础选项

属性说明类型默认值
label选项文本string-
value选项值string | number-
disabled是否禁用booleanfalse

分组选项

属性说明类型默认值
label分组标题string-
options分组内的选项Option[]-

Relcased under the Mit Lincense.