-
Notifications
You must be signed in to change notification settings - Fork 85
/
index.vue
78 lines (78 loc) · 1.72 KB
/
index.vue
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
<template>
<div>
<div class="loading">
<el-progress type="dashboard" :percentage="percentage" :color="colors"></el-progress>
<br />
<span class="zhong">正在加载中</span>
</div>
<div v-show="false">
<img src="/image/o_74911.jpg" alt />
<img src="/image/o_770659.jpg" alt />
<img src="/image/o_899029.jpg" alt />
<img src="/image/sh.jpg" alt />
<img src="/image/PChome.gif" alt />
<img src="/image/PCdetail.gif" alt />
<img src="/image/PC1.jpg" />
<img src="/image/PC2.jpg" />
<img src="/image/PC3.jpg" />
</div>
<div v-show="show">
<nuxt-child />
</div>
</div>
</template>
<script>
export default {
mounted() {
var _this = this;
let imgs = document.querySelectorAll("img");
this.num = imgs.length;
Array.from(imgs).forEach(item => {
let img = new Image();
img.onload = () => {
this.count++;
this.percentage = Math.floor((this.count / imgs.length) * 100);
};
img.src = item.getAttribute("src");
});
},
data() {
return {
count: 0,
show: false,
percentage: 0,
num: 0,
colors: [
{ color: "#f56c6c", percentage: 20 },
{ color: "#e6a23c", percentage: 40 },
{ color: "#5cb87a", percentage: 60 },
{ color: "#1989fa", percentage: 80 },
{ color: "#6f7ad3", percentage: 100 }
]
};
},
watch: {
count(val, oldval) {
if (val == this.num) {
this.show = true;
}
}
}
};
</script>
<style scoped>
.loading {
height: 200px;
width: 126px;
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: auto;
}
.zhong {
text-align: center;
display: block;
}
</style>