DropdownMenu 下拉菜单
基础用法
<van-dropdown-item v-model="value1" :options="option1" />
<van-dropdown-item v-model="value2" :options="option2" />
</van-dropdown-menu>
自定义菜单内容
<van-dropdown-menu>
<van-dropdown-item v-model="value" :options="option" />
<van-dropdown-item title="筛选" ref="item">
<van-cell center title="包邮">
<template #right-icon>
<van-switch v-model="switch1" size="24" active-color="#ee0a24" />
</template>
</van-cell>
<van-cell center title="团购">
<template #right-icon>
<van-switch v-model="switch2" size="24" active-color="#ee0a24" />
</van-cell>
<div style="padding: 5px 16px;">
<van-button type="danger" block round @click="onConfirm">
确认
</van-button>
</div>
</van-dropdown-item>
</van-dropdown-menu>
自定义选中态颜色
<van-dropdown-menu active-color="#1989fa">
<van-dropdown-item v-model="value1" :options="option1" />
<van-dropdown-item v-model="value2" :options="option2" />
</van-dropdown-menu>
禁用菜单
<van-dropdown-menu>
</van-dropdown-menu>
API
DropdownMenu Props
DropdownItem Props
参数 | 说明 | 类型 | 默认值 |
---|
value | 当前选中项对应的 value,可以通过v-model 双向绑定 | number | string | - |
title | 菜单项标题 | string | 当前选中项文字 |
options | 选项数组 | Option[] | [] |
disabled | 是否禁用菜单 | boolean | false |
lazy-render v2.8.5 | 是否在首次展开时才渲染菜单内容 | boolean | true |
title-class | 标题额外类名 | string | - |
get-container | 指定挂载的节点,用法示例 | string | () => Element | - |
DropdownItem Slots
名称 | 说明 |
---|
default | 菜单内容 |
title | 自定义标题,不支持动态渲染 |
DropdownItem 方法
Option 数据结构
键名 | 说明 | 类型 |
---|
text | 文字 | string |
value | 标识符 | number | string |
icon | 左侧图标名称或图片链接 | string |