Skip to content

XActionBar 操作按钮集

示例

基础用法

1

<template>
  <div>
    <XActionBar
      :items="items"
      mode="button"
      :disabled="disabled"
      @command="onCommand"></XActionBar>
  </div>
</template>
<script lang="ts" setup>
  import { XActionBar, type ActionBarItems } from '@vtj/ui';
  import { VtjIconBug, VtjIconApi, VtjIconPlus } from '@vtj/icons';

  const menus = [
    {
      command: 'a',
      label: '菜单 一'
    },
    {
      command: 'a1',
      label: '菜单 二'
    },
    {
      command: 'b',
      label: '菜单 三',
      divided: true,
      icon: VtjIconBug
    }
  ];

  const items: ActionBarItems = [
    {
      label: '按钮一',
      icon: VtjIconPlus,
      tooltip: '提示信息内容',
      draggable: true,
      onDragstart: (d: any, e: any) => {
        console.log(d, e);
      }
    },
    {
      label: '按钮二',
      icon: VtjIconBug,
      menus,
      onCommand(item: any) {
        console.log('onCommand', item);
      }
    },
    '|',
    {
      label: '按钮三',
      icon: VtjIconApi,
      badge: 1,
      onClick() {
        // alert('clicked!');
      }
    }
  ];

  const disabled = () => {
    return false;
  };

  const onCommand = (action: any, menu: any) => {
    console.log('onCommand', action, menu);
  };
</script>

mode:icon 效果

1

<template>
  <XActionBar
    :items="items"
    mode="icon"
    :disabled="disabled"
    @command="onCommand"></XActionBar>
</template>

<script setup lang="ts">
  import { XActionBar, type ActionBarItems } from '@vtj/ui';
  import { VtjIconBug, VtjIconApi, VtjIconPlus } from '@vtj/icons';

  const menus = [
    {
      command: 'a',
      label: '菜单 一'
    },
    {
      command: 'a1',
      label: '菜单 二'
    },
    {
      command: 'b',
      label: '菜单 三',
      divided: true,
      icon: VtjIconBug
    }
  ];

  const items: ActionBarItems = [
    {
      icon: VtjIconPlus,
      tooltip: '提示信息内容',
      draggable: true,
      onDragstart: (d: any, e: any) => {
        console.log(d, e);
      }
    },
    {
      icon: VtjIconBug,
      menus,
      onCommand(item: any) {
        console.log('onCommand', item);
      }
    },
    '|',
    {
      icon: VtjIconApi,
      badge: 1,
      onClick() {
        // alert('clicked!');
      }
    }
  ];

  const disabled = () => {
    return false;
  };

  const onCommand = (action: any, menu: any) => {
    console.log('onCommand', action, menu);
  };
</script>

<style scoped></style>

API

属性

属性名说明类型默认值
items动作项array-
mode模式string button|text|icon-
size尺寸stringdefault
type颜色类型string-
backgroundicon 背景设置,当 mode为 icon 时有效string always|hover|nonealways
circleicon 背景样式圆形,当 mode为 icon 时有效boolean-
disabled禁用boolean | () => boolean-
tooltiptooltip 配置object-
badgeBadge 配置object-
dropdownElDropdown 组件配置object-
buttonElButton 组件配置,mode为button时有效object-

事件

名称说明参数
click点击事件-
commandmenu菜单项点击事件-

Released under the MIT License.