Skip to content

BackTop 回到顶部

介绍

返回页面顶部的操作按钮。

基础用法

搭配 scrollerscrollbar 组件使用,在页面滚动超过一定距离后显示,点击后可返回滚动条顶部。

html
<vd-scroller scroll-y>
  <view class="content">
    ...
  </view>

  <vd-back-top />
</vd-scroller>

指定滚动条

通过 scroller 属性指定要监听的滚动条。

html
<vd-scroller name="page" scroll-y>
  <view class="content">
   ...
  </view>
</vd-scroller>

<vd-back-top scroller="page" />

滚动检测方向

通过 direction 属性指定滚动检测方向,可选值为 up down

html
<vd-scroller name="page" scroll-y>
  <view class="content">
  ...
  </view>
</vd-scroller>
<vd-back-top scroller="page" direction="down" />

自定义位置

通过 rightbottom 属性来设置组件距离右侧和底部的位置。

html
<vd-scroller name="page" scroll-y>
  <view class="content">
  ...
  </view>
</vd-scroller>
<vd-back-top scroller="page" right="10vw" bottom="10vh" />

API

Props

参数说明类型默认值
size尺寸大小string | number52
color颜色string-
right距离右侧的距离string | number30
bottom距离底部的距离string | number60
offset滚动高度超过该偏移量阈值时展示string | number200
direction滚动检测方向'up' | 'down''up'
scroller监听滚动事件的滚动条节点名称string-
z-index层级string | number9

代替原始 Props

参数说明类型默认值
custom-id根节点idstring-
custom-class根节点类名ClassValue-
custom-style根节点样式StyleValue-

Events

事件名说明回调参数
click点击时触发MouseEvent

Slots

名称说明
default自定义内容

赣ICP备2025061025号-1