Skip to content

t-fab

Fab 悬浮按钮

组件介绍

悬浮按钮组件,用于在页面中显示一个可展开/收起的悬浮按钮,支持多种展开方向,如垂直、水平以及圆形扩散,支持自由拖拽。

平台兼容

HarmonyH5AndroidiOS小程序UTS

基础用法

vue
<template>
  <t-fab direction="column-bottom" spacing="20rpx">
    <t-fab-item type="primary" @click="handleAdd">
      <t-icon name="plus" size="large" color="#fff"></t-icon>
    </t-fab-item>
    <t-fab-item type="success" @click="handleShare">
      <t-icon name="share" size="large" color="#fff"></t-icon>
    </t-fab-item>
    <t-fab-item type="warning" @click="handleEdit">
      <t-icon name="edit" size="large" color="#fff"></t-icon>
    </t-fab-item>
  </t-fab>
</template>

<script setup>
function handleAdd() {
  console.log('添加');
}

function handleShare() {
  console.log('分享');
}

function handleEdit() {
  console.log('编辑');
}
</script>

Props

属性名类型默认值说明可选值
sizeString"medium"组件尺寸large, medium, small, mini
typeString"primary"组件类型info, primary, error, warning, success
disabledBooleanfalse组件是否禁用true, false
hoverBooleanfalse是否有点击效果true, false
pathString""点击组件后跳转的页面路径-
effectString"normal"组件显示主题normal, dark, light, plain
menuCloseIconString"close"关闭时显示的图标-
menuOpenIconString"plus"展开时显示的图标-
menuBoxClassString""菜单按钮盒子的样式-
menuIconClassString""图标样式-
stateBooleanfalse按钮的展开折叠的状态true, false
directionString"row-left"按钮组展开的方向row-left, row-right, column-top, colunm-bottom, round
spacingString"20rpx"按钮之间的间距-
startRtateDegNumber0起始旋转角度-
rotateDegNumber60旋转角度-

Events

事件名说明回调参数
click点击时触发-
touchstart触摸开始时触发触摸事件对象
touchend触摸结束时触发触摸事件对象
touchmove触摸移动时触发触摸事件对象
touchcancel触摸取消时触发触摸事件对象

Slots

插槽名说明
default子按钮插槽,用于放置t-fab-item子组件
menu菜单按钮插槽,用于自定义菜单按钮的内容