-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.vue
More file actions
124 lines (111 loc) · 2.33 KB
/
app.vue
File metadata and controls
124 lines (111 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<template>
<NuxtLayout>
<NuxtPage/>
<Toast/>
<!--<div class="back-top" id="backTop" @click="goTop"></div>-->
</NuxtLayout>
</template>
<script>
export default {
setup() {
let {
ctx,
} = getCurrentInstance();
function handleScroll() {
ctx.scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
if (ctx.scrollTop > 140) {
document.getElementById('backTop').style.opacity = '1';
} else {
document.getElementById('backTop').style.opacity = '0';
}
}
function goTop() {
let timer = setInterval(() => {
let iSpeed = Math.floor(-ctx.scrollTop / 10);
document.documentElement.scrollTop = document.body.scrollTop = ctx.scrollTop + iSpeed;
if (ctx.scrollTop === 0) {
clearInterval(timer);
}
}, 10);
}
return {
handleScroll,
goTop,
};
},
mounted() {
// window.addEventListener('scroll', this.handleScroll);
},
destroyed() {
// document.removeEventListener('scroll', this.handleScroll);
},
};
</script>
<style lang="less">
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body, html {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif
}
a {
color: inherit;
text-decoration: none
}
html {
-webkit-font-smoothing: antialiased;
box-sizing: border-box;
text-size-adjust: 100%;
}
body {
background: #f8f8f8;
min-width: 960px;
min-height: 770px;
color: rgba(0, 0, 0, 0.87);
font-weight: 400;
font-size: 1rem;
line-height: 1.5;
letter-spacing: 0.00938em;
}
input:focus,
button:focus {
outline: none;
}
.back-top {
position: fixed;
bottom: 20px;
right: 20px;
left: auto;
width: 45px;
height: 45px;
background: url("~~/assets/images/icon_backTop.svg") no-repeat center center #373D47;
border-radius: 16px;
z-index: 1000;
opacity: 0;
transition: all .2s;
cursor: pointer;
&:hover {
background-color: #434954;
box-shadow: 0 5px 10px rgba(2, 6, 26, 0.36);
}
&:active {
background-color: #2A2F38;
}
}
@media (min-width: 1800px) {
.back-top {
right: auto;
left: 1730px;
}
}
@media (min-width: 0px) and (max-width: 1800px) {
.back-top {
right: 20px;
left: auto;
}
}
</style>