Skip to content

Select 选择器 ​

基础用法 ​

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

<script setup lang="ts">
import { ref } from 'vue'

const value = ref()
const options = [
  { label: '选项一', value: 'a' },
  { label: '选项二', value: 'b' },
  { label: '禁用项', value: 'c', disabled: true },
]
</script>

可清空 / 可过滤 ​

vue
<template>
  <lh-select v-model="value" :options="options" clearable />
  <lh-select v-model="value" :options="options" filterable placement="bottom" />
</template>

Props ​

属性说明类型默认值
modelValue (v-model)绑定值unknown—
options选项列表LhSelectOption[]—
size尺寸'small' | 'medium' | 'large'—
disabled禁用booleanfalse
clearable可清空booleanfalse
placeholder占位文本string—
filterable可过滤(MP 端在弹层内提供输入框)booleanfalse
placement弹层位置(12 种方位)LhPlacement'bottom'
customClass自定义类名string—
themeVars组件级主题变量Record<string, string>—
sx快速布局属性LhSxProps—

LhSelectOption ​

属性说明类型
label显示文案string
value值unknown
disabled禁用boolean

Events ​

事件说明回调参数
update:modelValue值变化(value)
change值变化(含清空时 undefined)(value)
visible-change弹层显隐(visible: boolean)

与 Vue3 版的差异

  • 弹层走 root-portal + 两帧异步度量定位(不是 absolute 定位)。
  • 键盘导航(↑↓ / Home / End)仅 H5,小程序无键盘事件,编译期移除——MP 端只能点击选项。
  • filterable 的过滤输入框在 MP 端渲染在弹层内部。