exportFun(){
        let _that = this
        const instance = this.axios.create({
          onDownloadProgress: function(ProgressEvent) {
            const load = ProgressEvent.loaded;
            const total = ProgressEvent.total;
            const progress = (load / total) * 100;
            console.log(progress);
            bar.style.width=(progress) + "%";
            $("#total").html( Math.floor(progress) + "%")
            if(progress == 100){
              _that.$emit('exportDataFun',this.needData)
              _that.isDownLoad = false
            }
          } 
        });
        let ajaxUrl,fileName
        if(this.isCanClick){
          let _that =this
          _that.isCanClick = false
          instance({
            url: ajaxUrl,
            method: "post",
            data: this.needData,
            responseType: "blob" //application/octet-stream
          }).then(res => {
            const data = res.data
              let r = new FileReader()
              r.onload = function () {
                try {
                  let resData = JSON.parse(this.result)
                  console.log(resData)
                  if (resData && resData['code'] && resData['code'] != '1000') {
                    _that.$Message.info(resData.msg);
                    _that.isDownLoad = false
                  }
                } catch (err) {
                  // 兼容ie11
                  if (window.navigator.msSaveOrOpenBlob) {
                    try {
                      const blobObject = new Blob([data])
                      window.navigator.msSaveOrOpenBlob(blobObject, fileName)
                    } catch (e) {
                      console.log(e)
                    }
                    return
                  }
                  this.download(data, fileName)
                  alert('导出成功')
                }
              }
              r.readAsText(data) // FileReader的API
          }).catch(e => {
            let msg = "网络异常";
            alert(msg);
          });

axios 如何获取下载文件的进度条的更多相关文章

  1. VC下载文件显示进度条

    VC下载文件显示进度条 逗比汪星人2009-09-18上传   by Koma http://blog.csd.net/wangningyu http://download.csdn.net/deta ...

  2. VC下载文件 + 显示进度条

    在codeproject里找了许久,发现这样一个VC下载文件并显示进度条的源码,于是添加了些中文注释: 1.下载线程函数: UINT DownloadFile(LPVOID pParam) { CWn ...

  3. webclient下载文件 带进度条

    private void button1_Click(object sender, EventArgs e) { doDownload(textBox1.Text.Trim()); } private ...

  4. UrlDownloadFile, 线程下载文件, 带进度条

    unit FileDownLoadThread; interface uses Classes, SysUtils, Windows, ActiveX, UrlMon; const S_ABORT = ...

  5. libcurl开源库在Win32程序中使用下载文件显示进度条实例

    一.配置工程引用libcurl库 #define CURL_STATICLIB #include "curl/curl.h" #ifdef _DEBUG #pragma comme ...

  6. Android 下载文件 显示进度条

    加入两个权限 一个是联网,另一个是读写SD卡 <uses-permission android:name="android.permission.INTERNET">& ...

  7. Android开发(24)---安卓中实现多线程下载(带进度条和百分比)

    当我们学完java中多线程的下载后,可以将它移植到我们的安卓中来,下面是具体实现源码: DownActivity.java package com.example.downloads; import ...

  8. Asp.Net上传大文件带进度条swfupload

    Asp.Net基于swfupload上传大文件带进度条百分比显示,漂亮大气上档次,大文件无压力,先看效果 一.上传效果图 1.上传前界面:图片不喜欢可以自己换 2.上传中界面:百分比显示 3.上传后返 ...

  9. JS原生上传大文件显示进度条-php上传文件

    JS原生上传大文件显示进度条-php上传文件 在php.ini修改需要的大小: upload_max_filesize = 8M    post_max_size = 10M    memory_li ...

随机推荐

  1. Linux–Nginx攻略

    什么是Nginx Nginx (“engine x”) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.Nginx是由Igor Sysoev为俄罗斯访问量第二的Ra ...

  2. Codeforces917E

    //#include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> #i ...

  3. [NOI2007]社交网络(最短路)

    [NOI2007]社交网络 Description 在社交网络(socialnetwork)的研究中,我们常常使用图论概念去解释一些社会现象.不妨看这样的一个问题. 在一个社交圈子里有n个人,人与人之 ...

  4. vsto c# 获取word里面的图片并保存

    internal void GetEmbeddedImages() { ; Document doc = Globals.ThisAddIn.Application.ActiveDocument; f ...

  5. .net core跨平台

    https://www.cnblogs.com/artech/p/7812811.html .net简介:https://baike.baidu.com/item/.NET/156737?fr=ala ...

  6. 微信小程序填坑之路其一:wx.request发送与服务端接受

    一.序言 应公司要求要求,要用小程序开发一个信息录入系统.没办法只能听话来填坑. 先介绍一下环境:客户端——小程序:服务端——java:数据库——mysql:服务器——centos7 需求:客户端输入 ...

  7. NOIp 数学 (小学奥数)

    Basic knowledge \[ C_n^m=\frac{n!}{m!(n - m)!} \] 快速幂 // Pure Quickpow inline int qpow(int n, int m, ...

  8. js数组声明+split()方法

    split()方法:var words = sentence.split(' '): "hello".split("", 3) //可返回 ["h&q ...

  9. python 使用xlsxwriter的方法属性

    http://xlsxwriter.readthedocs.io/format.html

  10. loj#501 「LibreOJ β Round」ZQC 的树列

    分析 代码(我的代码是瞎jb水过去的) #include<bits/stdc++.h> using namespace std; #define li long long li a[]; ...