Skip to content
On this page

组件库文档 tmui.design

下拉选项 Dropdown

用来制作下拉菜单,选项等。


🌶️ 下拉选项 Dropdown 示例

查看模拟效果
示例模板
vue
<template>
    <tm-app>
        <tm-sheet>
            <tm-text :fontSize="24" _class="font-weight-b" label="基础属性,更多玩法请前往文档。"></tm-text>
            <tm-divider></tm-divider>
            <view class="flex flex-between flex-row px-32">
                <tm-dropdown position="bl" color="grey-darken-4" :width="220"  :list="list">
                    <tm-text label="显示菜单"></tm-text>
                </tm-dropdown>
                <tm-dropdown :width="220" color="red" :list="list">
                    <tm-text label="样式1"></tm-text>
                </tm-dropdown>
                <tm-dropdown position="br" :width="220"  color="primary" linear="bottom" linearDeep="accent"  :list="list">
                    <tm-text label="右对齐"></tm-text>
                </tm-dropdown>
            </view>
        </tm-sheet>

    </tm-app>
</template>
<script lang="ts" setup>
import { ref, getCurrentInstance } from "vue"
import { onShow, onLoad } from "@dcloudio/uni-app";
import tmApp from "@/tmui/components/tm-app/tm-app.vue"
import tmSheet from "@/tmui/components/tm-sheet/tm-sheet.vue"
import tmText from "@/tmui/components/tm-text/tm-text.vue"
import tmDropdown from "@/tmui/components/tm-dropdown/tm-dropdown.vue"
import tmDivider from "@/tmui/components/tm-divider/tm-divider.vue"

const list = ref([
    { text: '苹果', id: '1' ,icon:"tmicon-collection"},
    { text: '菠萝', id: '2' ,icon:"tmicon-account-plus"},
    { text: '电话', id: '3' ,icon:"tmicon-phone"},
])
</script>

🌶️ 兼容性

APP-VUEAPP-NVUE小程序WEB/H5VUE3/TS
✔️✔️✔️✔️✔️

🌱 参数

本组件含有公共属性 公共属性

参数名类型默认值描述
textString''下拉选项的标题
iconColorString''下拉选项的图标颜色
iconString''下拉选项的图标
border[Number,String]0
round[Number,String]3圆角0-25,单位rpx
transprent[Boolean,String]false是否透明
colorString'white'
widthNumber0宽度,单位rpx
positionStringbctl上左,tc中,tr右。bc下左,bl中,br右。
listArray[]下拉选项的数据,格式见下方
rangKeyString"text"
disabledBooleanfalse是否禁用
haveArrowBooleantrue是否显示右箭头。

list数组数据格式:

ts
export interface itemList {
    text:string,
    iconColor?:string,
    icon?:string,
    [prop:string]:any
}

🌹 事件

事件名参数返回数据描述
clickindex: index,
data: {}
点击事件

🌽 slot插槽

默认default

🥗 ref方法

方法名参数返回值描述

😡 贡献者:小超1263375375