|
| 1 | +<template> |
| 2 | + <page-wraper> |
| 3 | + <demo-block> |
| 4 | + <wd-checkbox shape="square" size="large" v-model="isSquare">显示方形</wd-checkbox> |
| 5 | + <wd-checkbox shape="square" size="large" v-model="isCustomIcon">自定义图标</wd-checkbox> |
| 6 | + <wd-checkbox shape="square" size="large" v-model="isTop">自定义距离</wd-checkbox> |
| 7 | + <wd-checkbox shape="square" size="large" v-model="isStyle">自定义样式</wd-checkbox> |
| 8 | + <wd-checkbox shape="square" size="large" v-model="isDuration">自定义返回顶部滚动时间</wd-checkbox> |
| 9 | + </demo-block> |
| 10 | + <wd-backtop |
| 11 | + v-if="isCustomIcon" |
| 12 | + :scrollTop="scrollTop" |
| 13 | + :shape="isSquare ? 'square' : undefined" |
| 14 | + :top="isTop ? 600 : undefined" |
| 15 | + :customStyle="isStyle ? 'background: #007aff;color:white;' : undefined" |
| 16 | + :duration="isDuration ? 1000 : undefined" |
| 17 | + > |
| 18 | + <text :style="`color: ${isStyle ? 'white' : '#333'};`">TOP</text> |
| 19 | + </wd-backtop> |
| 20 | + <wd-backtop |
| 21 | + v-else |
| 22 | + :scrollTop="scrollTop" |
| 23 | + :shape="isSquare ? 'square' : undefined" |
| 24 | + :top="isTop ? 600 : undefined" |
| 25 | + :customStyle="isStyle ? 'background: #007aff;color:white;' : undefined" |
| 26 | + :duration="isDuration ? 1000 : undefined" |
| 27 | + ></wd-backtop> |
| 28 | + <view style="height: 2000px; color: red"></view> |
| 29 | + </page-wraper> |
| 30 | +</template> |
| 31 | +<script lang="ts" setup> |
| 32 | +import { onPageScroll } from '@dcloudio/uni-app' |
| 33 | +import { ref } from 'vue' |
| 34 | +
|
| 35 | +const scrollTop = ref(0) |
| 36 | +onPageScroll((e) => { |
| 37 | + scrollTop.value = e.scrollTop |
| 38 | +}) |
| 39 | +
|
| 40 | +const isSquare = ref(false) |
| 41 | +const isCustomIcon = ref(false) |
| 42 | +const isTop = ref(false) |
| 43 | +const isStyle = ref(false) |
| 44 | +const isDuration = ref(false) |
| 45 | +</script> |
| 46 | +<style lang="scss" scoped></style> |
0 commit comments