Appearance
BaseDropdown
下拉选择基础件,支持分组(type: 'group')、分割线(divider')与子项(children)。
用法
vue
<script setup lang="ts">
import { BaseDropdown } from '@qingpai/vue'
</script>
<template>
<BaseDropdown
:options="[
{ label: '正文', value: 'paragraph' },
{ type: 'divider' },
{ label: '标题', type: 'group', children: [{ label: '标题 1', value: 'h1' }] },
]"
placeholder="选择"
@change="onChange"
/>
</template>Props
| Prop | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
options | BaseDropDownOptionItem[] | — | 否 | 选项列表,支持 group / divider / children;label 支持 string 或 VNode(h() 结果,用于样式预览等富内容),选中后主按钮文字同步渲染该 VNode |
placeholder | string | — | 否 | 占位文字 |
trigger | DropdownProps['trigger'] | ['click'] | 否 | 触发方式 |
tooltip | string | — | 否 | 悬停提示文字 |
classes | Classes | — | 否 | 自定义类名(button) |
插槽
| 名称 | 参数 | 说明 |
|---|---|---|
default | { selectedKey: string } | — |
icon | — | — |
事件
| 名称 | 参数 | 说明 |
|---|---|---|
change | (value: string, option: BaseDropDownOptionItem) | — |