87 lines
1.5 KiB
Vue
Executable File
87 lines
1.5 KiB
Vue
Executable File
<template>
|
|
<view v-if="scrollTop>500" class="backTop" :class="{'mescroll-fade-in':isShowToTop}" @click="toTopClick">
|
|
<uni-icons type="arrowthinup" size="22" color="#fff"></uni-icons>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import uniIcons from "@/components/uni-icons/uni-icons.vue"
|
|
export default {
|
|
components:{uniIcons},
|
|
name: "backTop",
|
|
props: {
|
|
type: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
id: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
scrollTop: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
tab: {
|
|
type: Boolean,
|
|
default: false
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
isShowToTop: true
|
|
}
|
|
},
|
|
|
|
|
|
methods: {
|
|
toTopClick() {
|
|
this.isShowToTop = false; // 回到顶部按钮需要先隐藏,再执行回到顶部,避免闪动
|
|
if (this.tab) {
|
|
this.$emit('setScrollTop');
|
|
} else {
|
|
uni.pageScrollTo({
|
|
scrollTop: 0,
|
|
duration: 500
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
},
|
|
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.mescroll-lazy-in,
|
|
.mescroll-fade-in {
|
|
-webkit-animation: mescrollFadeIn .3s linear forwards;
|
|
animation: mescrollFadeIn .3s linear forwards;
|
|
}
|
|
|
|
.backTop {
|
|
background-color: #d9d9da;
|
|
z-index: 999;
|
|
position: fixed;
|
|
right: 10upx;
|
|
bottom: 120upx;
|
|
/* #ifdef H5 */
|
|
bottom: 120upx;
|
|
/* #endif */
|
|
width: 70upx;
|
|
height: 70upx;
|
|
border-radius: 50%;
|
|
transform: translateZ(0);
|
|
-webkit-transform: translateZ(0);
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
|
|
.backTop image {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
</style>
|