Skip to content

Menu

菜单组件

基础用法

横行与纵行两种风格(mode属性)

  • 横向展示组合
  • 2
  • 3
  • 4
  • 5

  • 纵行展示组合
  • 2
  • 3
  • 4
  • 5

❣️view the code❣️

vue
<xyMenu :onSelect="handleSelect" mode="horizontal">
  <xySubMenu index="0" title="横向展示组合">
    <xyMenuItem index="0-1">0-1</xyMenuItem>
    <xyMenuItem index="0-2">0-2</xyMenuItem>
    <xyMenuItem index="0-3">0-3</xyMenuItem>
  </xySubMenu>
  <xyMenuItem index="1">2</xyMenuItem>
  <xyMenuItem index="2">3</xyMenuItem>
  <xyMenuItem index="3">4</xyMenuItem>
  <xyMenuItem index="4">5</xyMenuItem>
</xyMenu>
<br />

<xyMenu :onSelect="handleSelect" :defaultOpenSubMenus="['0']">
  <xySubMenu index="0" title="纵行展示组合">
    <xyMenuItem index="0-1">0-1</xyMenuItem>
    <xyMenuItem index="0-2">0-2</xyMenuItem>
    <xyMenuItem index="0-3">0-3</xyMenuItem>
  </xySubMenu>
  <xyMenuItem index="1">2</xyMenuItem>
  <xyMenuItem index="2">3</xyMenuItem>
  <xyMenuItem index="3">4</xyMenuItem>
  <xyMenuItem index="4">5</xyMenuItem>
</xyMenu>

禁用菜单项

  • 展示组合
  • 2
  • 3
  • 4
  • 5

❣️view the code❣️

vue
<xyMenu :onSelect="handleSelect">
  <xySubMenu index="0" title="展示组合">
    <xyMenuItem index="0-1">0-1</xyMenuItem>
    <xyMenuItem  disabled index="0-2">0-2</xyMenuItem>
    <xyMenuItem index="0-3">0-3</xyMenuItem>
  </xySubMenu>
  <xyMenuItem index="1" disabled>2</xyMenuItem>
  <xyMenuItem index="2">3</xyMenuItem>
  <xyMenuItem index="3">4</xyMenuItem>
  <xyMenuItem index="4">5</xyMenuItem>
</xyMenu>

设置默认展开组合

  • 默认展开组合
  • 2
  • 默认不展开组合
  • 4
  • 5

❣️view the code❣️

vue
<xyMenu :onSelect="handleSelect" :defaultOpenSubMenus="['0']">
  <xySubMenu index="0" title="默认展开组合">
    <xyMenuItem index="0-1">0-1</xyMenuItem>
    <xyMenuItem index="0-2">0-2</xyMenuItem>
    <xyMenuItem index="0-3">0-3</xyMenuItem>
  </xySubMenu>
  <xyMenuItem index="1">2</xyMenuItem>
  <xySubMenu index="2" title="默认不展开组合">
    <xyMenuItem index="2-1">2-1</xyMenuItem>
    <xyMenuItem index="2-2">2-2</xyMenuItem>
    <xyMenuItem index="2-3">2-3</xyMenuItem>
  </xySubMenu>
  <xyMenuItem index="3">4</xyMenuItem>
  <xyMenuItem index="4">5</xyMenuItem>
</xyMenu>
属性名属性类型说明默认值
modeoneOf 'horizontal' | 'vertical'菜单展示风格vertical
defaultIndexnumber默认选中项0
defaultOpenSubMenusstring[]vertical模式下默认展开组合项[]
classNamestring自定义CSS类名-
onSelectMenuSelectCallback:(selectedIndex: string) => void选择选项的方法-
属性名属性类型说明默认值
indexstring唯一标志-
titlestring展示组合标题-
classNamestring自定义CSS类名-
属性名属性类型说明默认值
indexstring唯一标志-
disabledboolean是否禁用false
classNamestring自定义CSS类名-