FloatButton 悬浮按钮
用于全局页面的快捷操作入口,如回到顶部、帮助、客服等。
悬浮按钮是可以悬浮在页面上的可操作按钮。
何时使用
- 用于全局页面的快捷操作入口,如回到顶部、帮助、客服等。
- 悬浮在页面角落,不遮挡主要内容。
- 需要随时可访问的操作按钮。
导入
代码演示
基础用法
最基本的悬浮按钮,默认固定在右下角。
尺寸
支持三种尺寸:small、default、large。
形状
支持 round(圆形)和 square(方形)两种形状。
类型
支持 default、primary、colorful(多彩)三种类型。
点击跳转
通过 href 设置跳转地址,target 指定打开方式。
带 Tooltip 提示
通过 tooltip 属性添加鼠标悬浮提示。
带徽章
通过 badge 属性显示徽章数字。
禁用状态
自定义位置
通过 position 属性自定义固定位置。
自定义图标 Slot
通过 #icon slot 自定义图标内容。
悬浮按钮组
通过 FloatButtonGroup 传入 items 展示按钮组。
按钮组 - 点击触发
按钮组 - 水平方向
API
FloatButton
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| icon | 显示图标 | VNode | - |
| shape | 形状 | round | square | round |
| size | 尺寸 | small | default | large | default |
| type | 类型 | default | primary | colorful | default |
| colorful | 多彩悬浮按钮 | boolean | false |
| disabled | 禁用状态 | boolean | false |
| href | 点击跳转链接 | string | - |
| target | 链接打开方式 | string | - |
| tooltip | Tooltip 提示文字 | string | - |
| badge | 徽章数字 | number | string | - |
| position | 固定位置 | { top?, bottom?, left?, right? } | { bottom: 48, right: 48 } |
| class | 附加类名 | string | - |
| style | 附加样式 | CSSProperties | - |
FloatButton Events
| 事件 | 说明 | 回调参数 |
|---|---|---|
| onClick | 点击回调 | (e: MouseEvent) |
FloatButton Slots
| 名称 | 说明 |
|---|---|
| icon | 自定义图标 |
| default | 默认内容 |
FloatButtonGroup
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| items | 按钮组子项 | FloatButtonGroupItem[] | [] |
| trigger | 触发方式 | hover | click | hover |
| shape | 形状 | round | square | round |
| size | 尺寸 | small | default | large | default |
| disabled | 禁用状态 | boolean | false |
| direction | 展开方向 | vertical | horizontal | vertical |
| position | 固定位置 | { top?, bottom?, left?, right? } | { bottom: 48, right: 48 } |
| class | 附加类名 | string | - |
FloatButtonGroup Events
| 事件 | 说明 | 回调参数 |
|---|---|---|
| click | 点击子项回调 | (value: string, e: MouseEvent) |
FloatButtonGroup Slots
| 名称 | 说明 |
|---|---|
| default | 自定义触发器图标 |
FloatButtonGroupItem
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| content | 文本内容(Tooltip) | string | - |
| icon | 显示图标 | VNode | - |
| href | 点击跳转链接 | string | - |
| target | 链接打开方式 | string | - |
| badge | 徽章数字 | number | string | - |
| value | item 标识 | string | - |
尺寸对照
| size | 宽高 | 图标大小 |
|---|---|---|
| small | 40px | 16px |
| default | 48px | 20px |
| large | 56px | 24px |
