Skip to content

BackTop 返回顶部

长页面的浮动"回到顶部"按钮。滚动超过阈值自动显示,点击平滑滚动到顶部。

跨端支持:H5 监听 window 的 scroll 事件;小程序 / App 端使用 uni.onPageScroll 页面级生命周期。两端均使用 requestAnimationFrame 节流,避免高频触发。

基础用法

vue
<template>
  <see-backtop />
</template>

自定义位置

vue
<template>
  <see-backtop :right="50" :bottom="100" />
</template>

自定义图标

vue
<template>
  <see-backtop>
    <view class="custom-btn">
      <text>TOP</text>
    </view>
  </see-backtop>
</template>

Props

属性类型默认值说明
visibilityHeightnumber200显示阈值(px),滚动超过此值显示按钮
rightnumber20距离右边的距离(px)
bottomnumber80距离底部的距离(px)
zIndexnumber999层级
durationnumber300滚动动画时长(ms)
targetstring''指定滚动容器选择器(保留字段,当前实现以页面/window 滚动为准)
isCustombooleanfalse是否使用自定义插槽

Events

事件名参数说明
onClick-点击事件

Slots

插槽名说明
default自定义按钮内容

辽 ICP 备 2025070134 号