Skip to content

FloatButton 悬浮按钮

用于网站上的全局功能

代码演示

基础用法

最简单的用法

vue
<template>
  <a-float-button @click="handleClick" />
</template>
<script setup>
const handleClick = () => console.log('click')
</script>

含有气泡卡片的悬浮按钮

设置 tooltip 属性,即可开启气泡卡片。

vue
<template>
  <a-float-button
    tooltip="HELP INFO"
    :style="{
      right: '74px',
    }"
  ></a-float-button>

  <a-float-button
    :style="{
      right: '124px',
    }"
  >
    <template #tooltip>
      <div>Documents</div>
    </template>
  </a-float-button>
</template>

API

共同的 API

参数说明类型默认值
icon自定义图标slot-
description文字及其它内容string | slot-
tooltip气泡卡片的内容string | slot-
type设置按钮类型default | primarydefault
shape设置按钮形状circle | squarecircle
onClick点击按钮时的回调(event) => void-
href点击跳转的地址,指定此属性 button 的行为和 a 链接一致string-
target相当于 a 标签的 target 属性,href 存在时生效string-
badge带徽标数字的悬浮按钮(不支持 status 以及相关属性)BadgeProps-

共同的事件

事件名称说明回调参数
click设置处理 click 事件的处理器(event) => void

FloatButton.Group

参数说明类型默认值
shape设置包含的 FloatButton 按钮形状circle | squarecircle
trigger触发方式(有触发方式为菜单模式)click | hover-
open(v-model)受控展开boolean-

FloatButton.Group 事件

事件名称说明回调参数版本
openChange展开收起时的回调(open: boolean) => void

FloatButton.BackTop

参数说明类型默认值
duration回到顶部所需时间(ms)number450
target设置需要监听其滚动事件的元素() => HTMLElement() => window
visibilityHeight滚动高度达到此参数值才出现 BackTopnumber400
onClick点击按钮的回调函数() => void-