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 端渲染在彈層內部。