t-fab
Fab 悬浮按钮
组件介绍
悬浮按钮组件,用于在页面中显示一个可展开/收起的悬浮按钮,支持多种展开方向,如垂直、水平以及圆形扩散,支持自由拖拽。
平台兼容
| Harmony | H5 | Android | iOS | 小程序 | 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
| 属性名 | 类型 | 默认值 | 说明 | 可选值 |
|---|---|---|---|---|
| size | String | "medium" | 组件尺寸 | large, medium, small, mini |
| type | String | "primary" | 组件类型 | info, primary, error, warning, success |
| disabled | Boolean | false | 组件是否禁用 | true, false |
| hover | Boolean | false | 是否有点击效果 | true, false |
| path | String | "" | 点击组件后跳转的页面路径 | - |
| effect | String | "normal" | 组件显示主题 | normal, dark, light, plain |
| menuCloseIcon | String | "close" | 关闭时显示的图标 | - |
| menuOpenIcon | String | "plus" | 展开时显示的图标 | - |
| menuBoxClass | String | "" | 菜单按钮盒子的样式 | - |
| menuIconClass | String | "" | 图标样式 | - |
| state | Boolean | false | 按钮的展开折叠的状态 | true, false |
| direction | String | "row-left" | 按钮组展开的方向 | row-left, row-right, column-top, colunm-bottom, round |
| spacing | String | "20rpx" | 按钮之间的间距 | - |
| startRtateDeg | Number | 0 | 起始旋转角度 | - |
| rotateDeg | Number | 60 | 旋转角度 | - |
Events
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| click | 点击时触发 | - |
| touchstart | 触摸开始时触发 | 触摸事件对象 |
| touchend | 触摸结束时触发 | 触摸事件对象 |
| touchmove | 触摸移动时触发 | 触摸事件对象 |
| touchcancel | 触摸取消时触发 | 触摸事件对象 |
Slots
| 插槽名 | 说明 |
|---|---|
| default | 子按钮插槽,用于放置t-fab-item子组件 |
| menu | 菜单按钮插槽,用于自定义菜单按钮的内容 |