Skip to content

CommandBar-DEMO


vue
<div style="width: 100%;">
    <fv-CommandBar v-model="value" :options="options"></fv-CommandBar>
</div>

Compact Mode

vue
<div style="width: 100%;">
    <fv-CommandBar v-model="value" :options="options" :compact="true"></fv-CommandBar>
</div>

CommandBar-Toward Up


vue
<div style="width: 100%;">
    <fv-CommandBar :options="options" toward="up"></fv-CommandBar>
</div>

CommandBar-Right Space


vue
<div style="width: 100%;">
    <fv-CommandBar v-model="value" :options="options">
        <template v-slot:right-space>
            <span style="width: 40px; height: 40px; display: flex; justify-content: center; align-items: center;">
                <i class="ms-Icon ms-Icon--Error icon"></i>
            </span>
        </template>
    </fv-CommandBar>
</div>

CommandBar-Dark Theme


vue
<div style="width: 100%;">
    <fv-CommandBar :options="options" theme="dark"></fv-CommandBar>
</div>

CommandBar-Custom Background


vue
<div style="width: 100%;">
    <fv-CommandBar :options="options" theme="dark" background="rgba(0, 98, 158, 1)"></fv-CommandBar>
</div>

Propoties


属性(attr)类型(type)必填(required)默认值(default)说明(statement)
valueObjectNoN/A绑定当前选中的对象
optionsArrayYesN/ACommandBar 数据源
toward['down','up']Nodown下拉菜单的朝向
background[string(color)]NoN/ACommandBar 背景
compactBooleanNofalse紧凑样式
revealBorderColor[string(color)]NoN/A
revealBackgroundColor[string(color)]NoN/A
themeStringNosystem主题样式, 包含light, dark, system, custom几种样式

Events


事件名(Name)参数类型(args)说明(statement)
item-clickobject选中项目时返回当前数据项

Slot


  1. Right Space

用户可自定义 CommandBar 右侧内容

vue
<template v-slot:right-space>
  <i></i>
</template>

Data


  1. options

options中包含像ListView中的items一样的数据引用方式, 此外用户还可以指定:

  • 图标icon
  • 图标颜色iconColor
  • 触发函数func
  • 是否包含二级菜单secondary, secondary中的数据格式同options中一致
javascript
options = [
  { name: "", icon: "", iconColor: "", type: "", func: {}, show: true, secondary: [], disabled: false }
];

//e.g.//

options: [
  {
    name: "Add",
    icon: "Add",
    iconColor: "rgba(0, 90, 158, 1)",
    func: this.customFunc,
    secondary: [
      {
        name: "Email Message",
        func: this.customFunc,
        icon: "Mail",
        iconColor: "rgba(0, 98, 158, 1)",
        disabled: true
      },
      { type: "divider" },
      {
        name: "Calendar event",
        func: this.customFunc,
        icon: "WebAppBuilderModule"
      }
    ]
  },
  { name: "Edit", func: this.customFunc, icon: "SingleColumnEdit", disabled: true },
  { type: "divider" },
  { name: "Share", func: this.customFunc, icon: "Share" },
  {
    type: "more",
    secondary: [
      { name: "Move to", func: this.customFunc, icon: "MoveToFolder" },
      { name: "Copy to", func: this.customFunc, icon: "Copy" },
      { name: "Rename", func: this.customFunc, icon: "Rename" }
    ]
  }
];

特别地 0.0.61版本后支持采用函数式字段, 其中支持的字段包括name, disabled, icon, iconColor, type

MIT Licensed