文件上传进度条(基于vue+element)

直接上图

 <el-dialog title="上传文件" :visible.sync="dialoguploadingShow">
      <el-upload
        class="upload-demo"
        :auto-upload="false"
        ref="upload"
        action="Fake Action"
        :on-preview="handlePreview"
        :on-remove="handleRemove"
        :on-change="handleChange"
        :before-remove="beforeRemove"
        :on-progress="progressA"
        :on-success="success"
        multiple
        :file-list="fileList"
      >
        <el-button
          style="position: absolute; right: 140px; bottom: 20px;"
          type="primary"
          >选择文件</el-button
        >
      </el-upload>
      <el-select
        v-model="construction.form.region"
        style="width: 40%; position: relative; top: 20px"
        placeholder="请选择密级"
        @change="selectWorkName"
      >
        <el-option
          v-for="(item, i) in securityclassification"
          :key="i"
          :label="item.label"
          :value="item.value"
        ></el-option>
      </el-select>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialoguploadingClickSumit"
          >上传文件
        </el-button>
      </div>
    </el-dialog>
    
        this.$axios
          .post("api/docSmart/v1/system/docData/files", formData, {
            //上传进度
            headers: {
              authorization: this.token,
            },
            onUploadProgress: (progressEvent) => {
              console.log(progressEvent);
              console.log(formData);
              console.log(progressEvent.lengthComputable);
              let num = parseInt(
                ((progressEvent.loaded / progressEvent.total) * 100).toFixed(0)
              ); //百分比
              // file.onProgress({percent: num})
              console.log(num); //进度条
              this.percentage[i] = num;
              item.percentage = num;
              console.log("是否在线", navigator.onLine);
              console.log("网速", navigator.connection.downlink, "MB/s");
              //  this.downlink= navigator.connection.downlink;
              this.$store.commit("setdownlink", navigator.connection.downlink);
              // if (num == 100) {
              // this.fileList = [];
              // this.percentage = 0;
              // this.percentageshow = false;
              // }
            },
          })
          .then((res) => {})
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值