// 以下样式是定义的进度条占满全屏,而且会有种带遮罩的效果,如果需求不同请自己摸索一下
.bacc {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 999;
background: rgba(0, 0, 0, 0.6);
}
.bacc .el-progress {
position: absolute;
width: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
justify-content: center;
align-items: center;
}
// 以下是蹦跶的三个小球的样式
.wrapper {
position: absolute;
width: 200px;
height: 60px;
top: 55%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
justify-content: center;
align-items: center;
}
.circle {
width: 20px;
height: 20px;
position: absolute;
border-radius: 50%;
background-color: #e6ebf5;
left: 15%;
transform-origin: 50%;
animation: circle7124 0.5s alternate infinite ease;
}
@keyframes circle7124 {
0% {
top: 60px;
height: 5px;
border-radius: 50px 50px 25px 25px;
transform: scaleX(1.7);
}
40% {
height: 20px;
border-radius: 50%;
transform: scaleX(1);
}
100% {
top: 0%;
}
}
.circle:nth-child(2) {
left: 45%;
animation-delay: 0.2s;
}
.circle:nth-child(3) {
left: auto;
right: 15%;
animation-delay: 0.3s;
}
.shadow {
width: 20px;
height: 4px;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.9);
position: absolute;
top: 62px;
transform-origin: 50%;
z-index: -1;
left: 15%;
filter: blur(1px);
animation: shadow046 0.5s alternate infinite ease;
}
@keyframes shadow046 {
0% {
transform: scaleX(1.5);
}
40% {
transform: scaleX(1);
opacity: 0.7;
}
100% {
transform: scaleX(0.2);
opacity: 0.4;
}
}
.shadow:nth-child(4) {
left: 45%;
animation-delay: 0.2s;
}
.shadow:nth-child(5) {
left: auto;
right: 15%;
animation-delay: 0.3s;
}
下面重头戏来了o
// 定时器开启(通过某种方式触发定时器)
openTimer() {
this.isProgress = true;
// 进度慢
timer1 = setInterval(() => {
this.percentage++;
if (this.percentage > 85 && this.percentage <= 100) {
if (timer1) {
clearInterval(timer1);
}
// 进度快
timer2 = setInterval(() => {
this.percentage++;
if (this.percentage > 100) {
clearInterval(timer2);
// 加载完成,进度条消失
this.isProgress = false;
this.percentage = 0;
}
}, 50);
}
}, 200);
}
最后推荐一个网站,里面有好几种组件,样式种类很多也很酷炫哦进度条(el-progress)控制快慢(带遮罩的进度条)