2021-12-30 00:44:43 +08:00
|
|
|
|
::: anchor
|
|
|
|
|
:::
|
|
|
|
|
|
2021-12-20 07:19:40 +08:00
|
|
|
|
::: title 基础使用
|
|
|
|
|
|
2021-12-27 00:26:26 +08:00
|
|
|
|
###### 回到顶部组件的默认样式,<code>lay-backtop</code> 会自动寻找最近的可滚动祖先元素,也可以使用 `target` 属性指定触发滚动事件的元素,通过滑动来查看页面右下角的正方形按钮。
|
2021-12-20 07:19:40 +08:00
|
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
::: demo
|
|
|
|
|
<template>
|
2021-12-23 16:53:39 +08:00
|
|
|
|
<lay-backtop></lay-backtop>
|
2021-12-20 07:19:40 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
:::title 自定义
|
|
|
|
|
|
2021-12-20 23:36:51 +08:00
|
|
|
|
###### 回到顶部组件可自定义样式,限制宽高:50px \* 50px,<code>showHeight = 0</code> 将始终显示,<code>disabled</code> 属性禁用返回顶部。查看页面右下角的圆形按钮。
|
2021-12-20 07:19:40 +08:00
|
|
|
|
|
|
|
|
|
::: demo
|
|
|
|
|
|
2021-12-23 16:53:39 +08:00
|
|
|
|
<!-- 使用默认插槽自定义组件内容,也可以使用组件提供的样式属性快速定义常用样式,样式属性能满足大多数场景。lay-backtop组件可搭配 lay-tooltip 组件使用-->
|
2021-12-20 07:19:40 +08:00
|
|
|
|
<template>
|
2021-12-21 23:44:57 +08:00
|
|
|
|
<!-- 使用默认插槽自定义 -->
|
|
|
|
|
<lay-tooltip content="插槽自定义 backtop " position="left">
|
2021-12-23 16:53:39 +08:00
|
|
|
|
<lay-backtop @click="handlerClick" :showHeight="0" :bottom="160" bgcolor="#5FB878" circle disabled>
|
2021-12-21 23:44:57 +08:00
|
|
|
|
<lay-icon type="layui-icon-dialogue" size="30px"></lay-icon>
|
|
|
|
|
</lay-backtop>
|
|
|
|
|
</lay-tooltip>
|
|
|
|
|
<!-- 使用样式属性自定义 -->
|
|
|
|
|
<lay-tooltip content="属性自定义 backtop " position="left">
|
2021-12-23 16:53:39 +08:00
|
|
|
|
<lay-backtop :bottom="100" bgcolor="#5FB878" icon="layui-icon-up" circle></lay-backtop>
|
2021-12-21 23:44:57 +08:00
|
|
|
|
</lay-tooltip>
|
2021-12-20 07:19:40 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import { layer } from "../../../../src/index.ts"
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
setup() {
|
|
|
|
|
const handlerClick = () => {
|
2021-12-21 23:44:57 +08:00
|
|
|
|
layer.msg("layui-vue", { time: 1000 });
|
2021-12-20 07:19:40 +08:00
|
|
|
|
}
|
2021-12-21 23:44:57 +08:00
|
|
|
|
|
2021-12-20 07:19:40 +08:00
|
|
|
|
return {
|
|
|
|
|
handlerClick,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
2021-12-27 00:26:26 +08:00
|
|
|
|
::: title 挂载容器
|
2021-12-20 07:19:40 +08:00
|
|
|
|
|
2021-12-23 16:53:39 +08:00
|
|
|
|
###### 通过设置 <code>target</code> 和 <code>position="absolute"</code>参数,可对特定容器进行返回顶部操作
|
2021-12-20 07:19:40 +08:00
|
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
::: demo
|
|
|
|
|
|
|
|
|
|
<template>
|
2021-12-21 23:44:57 +08:00
|
|
|
|
<!-- 需要用一个 div 包裹触发滚动事件的目标元素和 lay-backtop 组件 -->
|
2021-12-27 00:26:26 +08:00
|
|
|
|
<div class="wrapper" style="width:700px; height:300px;">
|
2021-12-25 20:01:04 +08:00
|
|
|
|
<div id="scrollContent" style="overflow-y:auto; overflow-x:auto; width:700px; height:300px;background-color:whitesmoke;padding:10px;">
|
|
|
|
|
<lay-panel v-for="(n,index) in 50" :key="n" style="margin-top:5px;margin-bottom:5px;padding:10px;">内容</lay-panel>
|
2021-12-20 07:19:40 +08:00
|
|
|
|
</div>
|
2021-12-20 23:36:51 +08:00
|
|
|
|
<lay-backtop target="#scrollContent" :showHeight="100" :bottom="30" position="absolute"></lay-backtop>
|
2021-12-20 07:19:40 +08:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
::: title 属性
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
::: table
|
|
|
|
|
|
2021-12-27 00:26:26 +08:00
|
|
|
|
| 属性 | 描述 | 类型 | 默认值 | 可选值 |
|
|
|
|
|
| ------------ | --------------------------------------------- | ---------------- | ---------------- | ------------------------------ |
|
|
|
|
|
| target | 可选,触发滚动事件的对象 | string \| Window | `window` | `CSS/Element 选择器` `window` |
|
|
|
|
|
| showHeight | 可选,滚动高度达到该值后<br>显示回到顶部按钮 | number | `200` | — |
|
|
|
|
|
| disabled | 可选,禁用点击返回顶部 | boolean | `false` | `true` `false` |
|
|
|
|
|
| position | 可选,定位方式,特定容器内部<br>需设置为 absolute | string | `fixed` | `absolute` `fixed` |
|
|
|
|
|
| right | 可选,按钮距离页面右边距 | number | `30` | — |
|
|
|
|
|
| size | 可选,按钮大小 | string | —— | `medium` `small` |
|
|
|
|
|
| bottom | 可选,按钮距离页面底部位置 | number | `40` | `40` |
|
|
|
|
|
| bgcolor | 可选,背景颜色 | string | `#9F9F9F` | — |
|
|
|
|
|
| opacity | 可选,不透明度 | number | `0.95` | `0-1` |
|
|
|
|
|
| color | 可选,前景颜色 | string | `#FFFFFF` | — |
|
|
|
|
|
| borderRadius | 可选,添加圆角 | number \| string | `2` | e: 2 \| 2px \|50% |
|
|
|
|
|
| circle | 可选,使用圆形按钮 | boolean | `false` | `true` `false` |
|
|
|
|
|
| icon | 可选,图标类型 | string | `layui-icon-top` | `lay-icon`组件支持的所有类型 |
|
|
|
|
|
| iconSize | 可选,图标大小 | number | `30` | `30` |
|
|
|
|
|
| iconColor | 可选,图标颜色 | string | `#FFFFFF` | — |
|
2021-12-20 07:19:40 +08:00
|
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
::: title 事件
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
::: table
|
|
|
|
|
|
2021-12-27 00:26:26 +08:00
|
|
|
|
| 事件 | 描述 | 参数 |
|
2021-12-20 21:16:55 +08:00
|
|
|
|
| ------ | -------------------------- | -------- |
|
2021-12-21 23:44:57 +08:00
|
|
|
|
| click | 点击回到顶部按钮的回调函数 | event |
|
2021-12-20 07:19:40 +08:00
|
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
::: title 插槽
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
::: table
|
|
|
|
|
|
2021-12-27 00:26:26 +08:00
|
|
|
|
| 插槽 | 说明 |
|
2021-12-20 21:16:55 +08:00
|
|
|
|
| ------ | ---------- |
|
2021-12-27 00:26:26 +08:00
|
|
|
|
| default| 自定义内容 |
|
2021-12-20 07:19:40 +08:00
|
|
|
|
|
|
|
|
|
:::
|