Skip to content

Select 经典下拉框

本组件用于从底部弹出一个操作菜单,类似传统Web上的select下拉框组件, 供用户选择并返回结果。

4.4.0

平台差异说明

|App(vue)|App(uvue/uni-app-x)|App(nvue)|H5|小程序| |:-😐:-😐:-😐:-😐:-😐:-😐 |√|√|√|√|

基本使用

点击获取所点击选项ID

select回调事件带有一个object

html
<template>
	<view>
        <up-select v-model:current="cateId" label="分类"
            :options="cateList" @select="selectItem"></up-select>
	</view>
</template>
js
<script setup>  
import { ref, onMounted } from 'vue';  
  
// 响应式数据  
const cateId = ref('')
const cateList = ref([
    {
        id: '1',
        name: '分类1'
    },
    {
        id: '2',
        name: '分类2'
    },
    {
        id: '3',
        name: '分类4'
    },
])
  
// 方法  
const selectItem = (item) => {  
  console.log(item);  
};  
</script>

右侧演示页面源代码地址

点击以下链接以查看右侧演示页面的源码


 github  gitee

API

Props

参数说明类型默认值可选值
label选项名String'选项'true
options下拉选项列表Array[]-
current当前选中项目值v-model:currentStringNumber''
keyName选中时获取列表字段String'ud'-
labelName文案字段显示名称Stringname-
overlay点击后显示蒙版Booleantruefalse
overlayOpacity蒙版透明度Number0.01-
overlayStyle蒙版样式Object{}-
duration动画时间msNumber300-
showOptionsLabel是否显示选中项目名称Booleanfalsetrue
zIndex渲染层级Number11000-
itemColor下拉项目颜色String#333333-
iconColor下拉箭头图标颜色String#333333-
iconSize下拉箭头图标大小String13px-

Event

事件名说明回调参数版本
select点击列表项时触发--

ref Methods

方法名说明回调参数版本
openSelectref自定义控制开启下拉框--
closeSelect4.4.0ref自定义控制关闭下拉框--

Slot

名称说明
-(text)触发区域显示文案插槽
-(icon)右侧下拉箭头图标插槽
-(options)自定义下拉框插槽