项目中遇到的,用vue实现下:

 <template>
<div class="plLoading">
<div class="plLoadingContent">
<div class="plLoadingLogo">
<img src="http://static.crecgec.com/Kaipiao/loadingLogo.png"/>
</div>
<div class="plLoadingCon">
<div class="plLoadingShow" ref="plLoadingShow" :style="{width: plsStyleWidth}"></div>
<div class="plLoCir" ref="plLoCir" :style="{left: plcStyleLeft}" v-show="plcShow"></div>
</div>
<div class="plLoadingNum" ref="plLoadingNum">%</div>
</div>
<!--测试用的,使用的时候,在父组件创建一个隐藏的Ddiv,里面放入这个页面用到的所有img-->
<div class="imgsHidden displayNone">
<img class="hImg" src="http://static.crecgec.com/Kaipiao/countDownTitle.png">
<img class="hImg" src="http://static.crecgec.com/Kaipiao/countDown.png">
<img class="hImg" src="http://static.crecgec.com/Kaipiao/countDown1.png">
<img class="bImg" src="http://static.crecgec.com/Kaipiao/background.png">
<img class="hImg" src="http://static.crecgec.com/Kaipiao/loadingLogo.png">
</div>
</div>
</template> <script type="text/ecmascript-6">
import $ from 'jquery' export default {
props: {
eleH: {
type: String,
default: 'hImg'
},
eleB: {
type: String,
default: 'bImg'
},
dataIsOk: {
type: Boolean,
default: false
}
},
data () {
return {
plsStyleWidth: , // plLoadingShow的初始width
plcStyleLeft: , // plLoCir的初始left值
plcShow: true, // plLoCir初始是显示状态
backImgLoading: false, // 背景图片是否加载成功(40)
otherImgLoading: false, // 头部、底部图片加载成功(40)
dataLoading: '', // 后台返回的数据加载成功(20)
lodingWidth: ,
otherImgLength: ,
otherNum: ,
backImgLength: ,
backNum:
}
},
watch: {
// 整个也没被分为三部分:背景图、其他图片、数据
// 监控otherImgLoading,(其他图片加载成功),this.lodingWidth增加40
otherImgLoading () {
this.lodingWidth = this.lodingWidth +
},
// 监控otherImgLoading,(背景图片加载成功),this.lodingWidth增加40
backImgLoading () {
this.lodingWidth = this.lodingWidth +
},
// 监控dataIsOk,(数据加载成功,这个有父组件传递过来),this.lodingWidth增加20
dataIsOk () {
if (this.dataIsOk) {
this.lodingWidth = this.lodingWidth +
}
},
// 监控lodingWidth的值
lodingWidth () {
if (this.lodingWidth <= ) {
this.setLoadingWidthTimer(this.lodingWidth)
}
},
// 监控plcStyleLeft(圆球的left值),如果值为484px(自己设置的),表明圆球到了最右边
// 圆球隐藏
plcStyleLeft () {
if (this.plcStyleLeft === '484px') {
setTimeout(() => {
this.plcShow = false
this.hasScroll()
this.$emit('tipShow', {loadingIsShow: false})
}, )
}
}
},
mounted () {
this.isOtherImgLoading(this.eleH)
this.isBackImgLoading(this.eleB)
this.noScroll()
},
methods: {
// 设置width、left
setLoadingWidthTimer (newPllsWidth) {
if (newPllsWidth <= ) {
setTimeout(() => {
this.plsStyleWidth = ( * newPllsWidth / ) + 'px'
this.plcStyleLeft = ( * newPllsWidth / ) + 'px'
this.$refs.plLoadingNum.innerHTML = newPllsWidth + '%'
}, )
} else if (newPllsWidth <= ) {
setTimeout(() => {
this.plsStyleWidth = ( * newPllsWidth / ) + 'px'
this.plcStyleLeft = ( * newPllsWidth / ) + 'px'
this.$refs.plLoadingNum.innerHTML = newPllsWidth + '%'
}, )
} else {
setTimeout(() => {
this.plsStyleWidth = ( * newPllsWidth / ) + 'px'
this.plcStyleLeft = ( * newPllsWidth / ) + 'px'
this.$refs.plLoadingNum.innerHTML = newPllsWidth + '%'
}, )
}
},
// 弹出层显示的时候,没有滚动条
noScroll () {
document.body.style.cssText = 'overflow:hidden;'
},
// 弹出层消失后,滚动条显示
hasScroll () {
document.body.style.cssText = 'overflow:auto;'
},
isOtherImgLoading (ele) {
this.otherImgLength = $('.' + ele).length
let _this = this
if (this.otherImgLength > ) {
$('.' + ele).each(function () {
$(this).on('load', function () {
_this.otherNum = _this.otherNum +
if (_this.otherImgLength === _this.otherNum) {
_this.otherImgLoading = true
}
})
})
} else {
this.otherImgLoading = true
}
},
isBackImgLoading (ele) {
this.backImgLength = $('.' + ele).length
let _this = this
if (this.backImgLength > ) {
$('.' + ele).each(function () {
$(this).on('load', function () {
_this.backNum = _this.backNum +
if (_this.backImgLength === _this.backNum) {
_this.backImgLoading = true
}
})
})
} else {
this.backImgLoading = true
}
}
}
}
</script> <style>
.plLoading{
width: %;
height: %;
position: absolute;
left: ;
top: ;
z-index: ;
background-color: #00101d;
}
.plLoadingContent{
width: 500px;
height: 220px;
position: absolute;
margin: auto;
top: %;
left: %;
margin-top: -110px;
margin-left: -250px;
}
.plLoadingLogo{
height: 60px;
}
.plLoadingCon{
width: 500px;
height: 16px;
margin-top: 100px;
border-radius: 8px;
background-color: #;
}
.plLoadingShow{
transition: width .5s;
height: 16px;
border-radius: 8px;
background-color: #0062b2;
position: absolute;
}
.plLoCir{
transition: left .5s;
position: absolute;
width: 16px;
height: 16px;
border-radius: 8px;
background-color: #0062b2;
box-shadow: 20px #008cff;
}
.plLoadingNum{
font-size: 14px;
color: #0062b2;
margin-top: 20px;
}
.displayNone{
display: none;
}
</style>

Vue 实现loading进度条的更多相关文章

  1. Android loading进度条使用简单总结

    在这里,总结一下loading进度条的使用简单总结一下. 一.说起进度条,必须说说条形进度条,经常都会使用到嘛,特别是下载文件进度等等,还有像腾讯QQ安装进度条一样,有个进度总给人良好的用户体验. 先 ...

  2. JavaScript之Loading进度条

    一个loading进度条,定义一个fakeProgress方法,定位一个URL,然后setTimeout设置跳转时间我们就能看到我们要打开的URL网址了. 这个链接我就直接链接到我的新浪博客去了,算是 ...

  3. ASP.NET 给Web中的网页添加Loading进度条形式

    前段时间客户提了一个需求,要求给网站中某些功能添加进度条形式,因为某些功能查询的数据量太大,经常会出现点击Search按钮,但是没有任何反应的情况,会让用户以为网站挂掉了,导致投诉的事情发生,所以客户 ...

  4. 模态框的理解 ,jQ: loading,进度条, 省级联动 表单验证 插件

    模态框: 打开一个弹框 不关闭它就不能做框外的操作 必须关闭或弹出另外的弹框 加载延迟loading + 进度条只要有请求 就处理一下监控ajax 全局事件jquery: $('#box').ajax ...

  5. Unity3d中制作异步Loading进度条所遇到的问题

    背景 通常游戏的主场景包括的资源较多,这会导致载入场景的时间较长.为了避免这个问题,能够首先载入Loading场景.然后再通过Loading场景来载入主场景. 由于Loading场景包括的资源较少,所 ...

  6. vue轻量进度条

    **### vue------ mode 好玩东西+1: 轻量级进度条: 1.引入 import NProgress from 'nprogress'; // progress bar import ...

  7. spin.js无图片实现loading进度条,支持但非依赖jquery

    特点: 1.无图片,无外部CSS 2.无依赖(支持jQuery,但非必须) 3.高度可配置 4.分辨率无关 5.旧版本IE不支持时,采用VML支持 6.使用关键帧动画,采用setTimeout() 7 ...

  8. unity3d___UGui中如何创建loading...进度条

    http://blog.sina.com.cn/s/blog_e82e8c390102wh2z.html 实现方法:通过Image组件中Image Type属性中Fill Amount,通过代码改变F ...

  9. Vue/React圆环进度条

    数据展示,一直是各行各业乐此不疲的需求,具体到前端开发行业,则是各种各种图表数据展示,各种表格数据展示,烦不胜烦(繁不胜繁)! 前几天刚做了折线图.柱状图.饼状图之类的图表数据展示效果,今天又碰到了类 ...

随机推荐

  1. 洛谷 P1053 逛公园 解题报告

    P3953 逛公园 问题描述 策策同学特别喜欢逛公园. 公园可以看成一张\(N\)个点\(M\)条边构成的有向图,且没有自环和重边.其中1号点是公园的入口,\(N\)号点是公园的出口,每条边有一个非负 ...

  2. bzoj4784【zjoi2017】仙人掌

    题目描述 如果一个无自环无重边无向连通图的任意一条边最多属于一个简单环,我们就称之为仙人掌.所谓简单环即不经过 重复的结点的环. 现在九条可怜手上有一张无自环无重边的无向连通图,但是她觉得这张图中的边 ...

  3. Socket通信的简单例子

    客户端代码: package com.bobohe.socket; import java.io.*; import java.net.*; public class TalkClient { pub ...

  4. Nginx Configuration 免费HTTPS加密证书

    Linux就该这么学 2018-05-11 实验环境:CentOS Linux release 7.3.1611 (Core) 内核版本:Linux version 3.10.0-514.el7.x8 ...

  5. 利用ImageOps调整图片的Aspect Ratio(给图片添加borders)

    # -*- coding: utf-8 -*- #******************** # 改变图片的纵横比(aspect retio) # 使用ImageOps.expand() # Image ...

  6. Dubbo学习笔记1:使用Zookeeper搭建服务治理中心

    Zookeeper是Apache Hadoop的子项目,是一个树形的目录服务,支持变更推送,适合作为Dubbo服务的注册中心,工业强度较高,推荐生成环境使用. , 下面结合上图介绍Zookeeper在 ...

  7. 对 jQuery 中 data 方法的误解

    一直以来都认为新版本中 data 是调用 dataset 实现的,对于低版本IE则采用 getAttribute其实一直是我误解了,也不知道最初这个想法是怎么来的.难道我被盗梦了? 今天 谢亮 兄弟和 ...

  8. 读懂复杂C声明的黄金法则

    在网上遇见felix,他让我读 http://www.felix021.com/blog/read.php?2072,读完之后觉得收获很大,需要练习一下. 黄金法则:从声明的变量开始,先向右看,再向左 ...

  9. OpenCV3.4.1+vs2017安装及配置

    一.OpenCV3.4.1下载与安装 1.OpenCV3.4.1下载 可以去OpenCV官网上下载http://opencv.org/ 然后找到对应的系统环境就可以下载了,当然了官网上下载会很慢,推荐 ...

  10. (转)Oracle 字符集的查看和修改

    一.什么是Oracle字符集 Oracle字符集是一个字节数据的解释的符号集合,有大小之分,有相互的包容关系.ORACLE 支持国家语言的体系结构允许你使用本地化语言来存储,处理,检索数据.它使数据库 ...