Skip to content

DropdownTop 顶端下拉

从页面最顶端向下平滑滑出的全宽下拉筛选组件,常用于列表页顶部综合筛选、排序切换。


代码示例

vue
<template>
  <mu-button type="primary" block @click="show = true">
    打开顶端下拉菜单筛选 ▾ (当前: {{ selectedValue }})
  </mu-button>

  <mu-dropdown-top
    v-model:show="show"
    v-model:value="selectedValue"
    :items="filterItems"
    @select="onSelect"
  />
</template>

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

const show = ref(false)
const selectedValue = ref('all')
const filterItems = ref([
  { label: '全部排序', value: 'all' },
  { label: '按价格从低到高', value: 'price_asc' },
  { label: '按价格从高到低', value: 'price_desc' },
  { label: '按销量优先', value: 'sales' }
])

const onSelect = (item) => {
  console.log('选中筛选:', item.label)
}
</script>

API 属性说明 (Props)

参数名说明类型可选值默认值
v-model:show控制顶端下拉面板的显隐Booleantrue | falsefalse
v-model:value当前选中的选项值String | Number-''
items下拉筛选选项列表Array-[]
top面板距离顶部的偏移位置 (支持 '88rpx' 等)Number | String-0
activeColor选中项文案与打勾图标高亮颜色String-''

事件说明 (Events)

事件名说明回调参数
update:showv-model:show 双向绑定更新(show: boolean)
update:valuev-model:value 双向绑定更新(value: String | Number)
select点击选项时触发(item: Object | String)
close面板完全收回关闭时触发-

插槽说明 (Slots)

插槽名说明
default下拉面板底部的自定义扩展面板内容

基于 MIT 协议开源发行

H5 模拟器 (dropdown-top)☀️🔄