Dropdown 下拉菜单


展示折叠的下拉菜单

基础用法

基础的下拉菜单,使用方式是用 AtDropdownAtDropdownMenuAtDropdownItem 的组合

Dropdown下拉菜单 - 图1

  1. <at-dropdown>
  2. <span>下拉菜单 <i class="icon icon-chevron-down"></i></span>
  3. <at-dropdown-menu slot="menu">
  4. <at-dropdown-item>深圳</at-dropdown-item>
  5. <at-dropdown-item>广州</at-dropdown-item>
  6. <at-dropdown-item disabled>上海</at-dropdown-item>
  7. <at-dropdown-item divided>北京</at-dropdown-item>
  8. <at-dropdown-item>杭州</at-dropdown-item>
  9. </at-dropdown-menu>
  10. </at-dropdown>
  11. <at-dropdown>
  12. <at-button size="small">下拉菜单 <i class="icon icon-chevron-down"></i></at-button>
  13. <at-dropdown-menu slot="menu">
  14. <at-dropdown-item>深圳</at-dropdown-item>
  15. <at-dropdown-item>广州</at-dropdown-item>
  16. <at-dropdown-item disabled>上海</at-dropdown-item>
  17. <at-dropdown-item divided>北京</at-dropdown-item>
  18. <at-dropdown-item>杭州</at-dropdown-item>
  19. </at-dropdown-menu>
  20. </at-dropdown>

激活的方式

下拉菜单默认使用 hover 的方式激活,可通过参数 trigger 更换激活的方式,支持 clickhoverfocus

Dropdown下拉菜单 - 图2

  1. <at-dropdown>
  2. <at-button size="small">Hover 菜单 <i class="icon icon-chevron-down"></at-button>
  3. <at-dropdown-menu slot="menu">
  4. <at-dropdown-item name="shenzhen">深圳</at-dropdown-item>
  5. <at-dropdown-item name="guangzhou">广州</at-dropdown-item>
  6. <at-dropdown-item name="shanghai" disabled>上海</at-dropdown-item>
  7. <at-dropdown-item name="beijin" divided>北京</at-dropdown-item>
  8. </at-dropdown-menu>
  9. </at-dropdown>
  10. <at-dropdown trigger="click">
  11. <at-button size="small">Click 菜单 <i class="icon icon-chevron-down"></at-button>
  12. <at-dropdown-menu slot="menu">
  13. <at-dropdown-item name="shenzhen">深圳</at-dropdown-item>
  14. <at-dropdown-item name="guangzhou">广州</at-dropdown-item>
  15. <at-dropdown-item name="shanghai" disabled>上海</at-dropdown-item>
  16. <at-dropdown-item name="beijin" divided>北京</at-dropdown-item>
  17. </at-dropdown-menu>
  18. </at-dropdown>

菜单的对齐方式

设置属性 placement 更改下拉菜单的对齐方式

Dropdown下拉菜单 - 图3

  1. <at-dropdown placement="bottom-right">
  2. <at-button size="small">Hover 菜单 <i class="icon icon-chevron-down"></at-button>
  3. <at-dropdown-menu slot="menu">
  4. <at-dropdown-item name="shenzhen">深圳</at-dropdown-item>
  5. <at-dropdown-item name="guangzhou">广州</at-dropdown-item>
  6. <at-dropdown-item name="shanghai" disabled>上海</at-dropdown-item>
  7. <at-dropdown-item name="beijin" divided>北京</at-dropdown-item>
  8. </at-dropdown-menu>
  9. </at-dropdown>

下拉菜单触发的事件

点击菜单选项触发事件 on-dropdown-command,返回 AtDropdownItemname

Dropdown下拉菜单 - 图4

  1. <at-dropdown placement="bottom-right" @on-dropdown-command="handleCommand">
  2. <at-button size="small">Hover 菜单 <i class="icon icon-chevron-down"></at-button>
  3. <at-dropdown-menu slot="menu">
  4. <at-dropdown-item name="shenzhen">深圳</at-dropdown-item>
  5. <at-dropdown-item name="guangzhou">广州</at-dropdown-item>
  6. <at-dropdown-item name="shanghai" disabled>上海</at-dropdown-item>
  7. </at-dropdown-menu>
  8. </at-dropdown>

Dropdown 参数

参数说明类型可选值默认值
trigger触发 Dropdown 的方式Stringclick, hover, focushover
placement下拉框的对齐方式Stringtop, top-left, top-right, bottom, bottom-left, bottom-rightbottom

Dropdown 事件

事件名称说明返回值
on-dropdown-command菜单项点击的时候触发点击的菜单的 name

DropdownItem 参数

参数说明类型可选值默认值
name菜单的值String--
disabled是否禁用Boolean-false
divided是否添加分割线Boolean-false