vue 上传进度显示
参考资料:
https://ask.csdn.net/questions/767017
https://www.cnblogs.com/best-fyx/p/11363506.html
我使用的是element-ui中的 Upload 上传 组件,最终效果

组件对应的 on-progress事件绑定的方法
handleProgressing(event, file, fileList) {
var per = (event.loaded * ) / event.total
var size = event.total / /
this.step = 2.77
this.timeSpan =
per = per * 0.75
if (per > 72.1) {
if (!this.isTimer)
if (size > ) {
this.step = 1.43
this.timeSpan =
}
if (size > ) {
this.step = 0.43
this.timeSpan =
}
if (size > ) {
this.step = 0.33
this.timeSpan =
}
if (size > ) {
this.step = 0.21
this.timeSpan =
}
if (size > ) {
this.step = 0.17
this.timeSpan =
}
if (size > ) {
this.step = 0.09
this.timeSpan =
}
if (size > ) {
this.step = 0.07
this.timeSpan =
}
if (size > ) {
this.step = 0.06
this.timeSpan =
}
if (size > ) {
this.step = 0.05
this.timeSpan =
}
if (size > ) {
this.step = 0.03
this.timeSpan =
}
//一定在这里定义timer变量,然后在定时器里面清除,不然不好用
var isTimer1 = setInterval(() => {
if (this.p >= ) this.step = 0.01
this.p = parseFloat(this.p) + this.step
if (this.p >= 99.97) this.p = 99.99
this.processStr = this.p.toFixed() + '%'
console.log(this.processStr)
if ((this.processStr = '100%')) {
console.log('window')
window.clearInterval(isTimer1)
}
}, this.timeSpan)
// console.log(' this.isTimer')
// console.log(this.isTimer)
} else {
this.processStr = per.toFixed() + '%'
}
}
上传成功的方法:
successlUpload() {
this.processStr = '100%' //设置这个标志位,定时器里面的清除逻辑就会执行
this.isTimer =
this.$refs.uploadFile.abort()
this.uploading = false
},
上传成功后把显示的字符串改为100%就可以了。
我这个写的原因是我的上传文件分两块。
过程: 1.vue上传文件到接口服务器(webapi)
2.接口把文件上传到azure
所以我把上传进度显示改为模拟的了,按照文件的大小设置上传进度的step。
你们直接报错到服务器的话可以不使用我代码的这一块。
vue 上传进度显示的更多相关文章
- silverlight漂亮的文件上传进度显示原理及示例
silverlight漂亮的文件上传进度显示原理及示例 作者:chenxumi 出处:博客园 2009/11/27 13:37:11 阅读 1219 次 概述:在网站根目录web.config里配 ...
- 使用element UI el-upload组件实现视频文件上传及上传进度显示方法总结
实现效果: 上传中: 上传完成: 代码: <el-form-item label="视频上传" prop="Video"> <!-- acti ...
- axios+Vue上传文件显示进度
一,前言 最近在用Vue,然后上传文件时需要显示进度,于是网上搜了一下,经过自己实测终于也弄明白了 二,效果 三,代码 HTML代码 <div id="app"> &l ...
- servlet上传文件+上传进度显示
效果图 功能描述 1.使用jquery.form.js实现异步上传功能,并显示上传进度 2.servlet中保存上传的文件到指定文件夹 3.查看已经上传的文件 4.不同文件类型用不同图标显示 下载 h ...
- 安卓自定义View实现图片上传进度显示(仿QQ)
首先看下我们想要实现的效果如下图(qq聊天中发送图片时的效果): 再看下图我们实现的效果: 实现原理很简单,首先我们上传图片时需要一个进度值progress,这个不管是自己写的上传的方法还是使用第三方 ...
- 阿里云 oss 小文件上传进度显示
对阿里云OSS上传小文件时的进度,想过两个方法:一是.通过多线程监測Inputstream剩余的字节数来计算,可是由于Inputstream在两个线程中共用,假设上传线程将Inputstream关闭, ...
- 一个简单的ajax上传 上传进度显示
本例用了jquery.form.js请到演示页面查看 CSS Code <style> form { display: block; margin: 20px auto; backgrou ...
- ajax上传文件显示进度
下面要做一个ajax上传文件显示进度的操作,文末有演示地址 这里先上代码: 1.前端代码 upload.html <!DOCTYPE html> <html lang="e ...
- vue多文件上传进度条 进度不更新问题
转自 hhttp://www.cnblogs.com/muge10/p/6767493.html 感谢这位兄弟的文章,之前因为这个问题 ,我连续在sgmentflow上提问过多次,完全没人能回答.谢谢 ...
随机推荐
- Python规范:提高可读性
PEP 8 规范 PEP 是 Python Enhancement Proposal 的缩写,翻译过来叫"Python 增强规范". 缩进规范 PEP 8 规范告诉我们,请选择四个 ...
- python 生成 树状结构
树状结构: 字典里只有一个键值对, key 为根, 值为一个列表, 列表里的某个或多个元素可以再进行分支(分支还是列表) 比如: 邮件的发件人, 收件人, 转发关系树状结构 forwarding_re ...
- zsh: command not found: 解决方法
问题原有:mac中安装了my zsh [https://www.cnblogs.com/dadonggg/p/11027454.html] ,但是造成了在使用vscode的时候,提示”zsh: com ...
- Linux—网络防火墙详解
一.防火墙基本知识 二.firewall防火墙 # 安装firewalld [root@localhost ~]# apt-get install firewalld [root@localhost ...
- Windows下使用ssh-add报错 Error connecting to agent: No such file or directory
Windows下使用ssh-add报错 Error connecting to agent: No such file or directory 环境信息 操作系统:windows 10 终端:Win ...
- cookie:
Django Django处理一个请求的流程 在浏览器的地址栏中输入地址,回车,发了一个GET请求 wsgi模块接收了请求,将请求的相关信息封装成request对象 根据地址找到对应函数 执行函数获取 ...
- java加密类
java.security.KeyStore KeyStore ks = KeyStore.getInstance(type); KeyStore ks = KeyStore.getInstance( ...
- Codechef September Challenge 2019 Division 2
Preface 这确实应该是我打过的比较水的CC了(其实就打过两场) 但由于我太弱了打的都是Div2,所以会认为上一场更简单,其实上一场Div的数据结构是真的毒 好了废话不多说快速地讲一下 A Eas ...
- [技术]SYZOJ 实现网站与评测端分离
SYZOJ 实现分布式评测 这篇博客的起因是学校的OJ因为高考被切断了, 但是我的公网OJ是个实现很不清真的UOJ而且上面只有1core和1GB内存. 费了一些周折部署好syzoj之后大家喜闻乐见地被 ...
- BDFramework.Core 学习
x哥(懂的都懂)的框架, 拿点代码过来做注释. 想了解详情可以去他的github https://github.com/yimengfan/BDFramework.Core # Object file ...