zoukankan      html  css  js  c++  java
  • 使用Element UI的el-upload 上传文件

    <el-upload
                class="upload_csv"
                ref="upload"
                accept=".csv"
                :action="uploadAPI"
                :multiple="false"
                :limit="1"
                :headers="avatarHeader"
                :on-success="handleSuccess"
                :on-error="handleError"
                :on-progress="hanleProgressing"
              >
                <el-button class="import" size="mini" :loading="isImporting"
                  ><i class="el-icon-download"></i>&nbsp;&nbsp;{{
                    $t('asset.import')
                  }}</el-button
                >
    </el-upload>
    uploadAPI: process.env.BASE_API + '/importTag',  // 上传的Url地址
    computed: {
        avatarHeader() {
          return {
            Authorization: 'bearer ' + getToken()
          }
        }
    }
    // 上传成功的回调
    handleSuccess(response, file, fileList) {
          if (response.success) {
            this.handleResetClear()
            this.getUploadStatus()
            const _this = this
            this.uploadTimer = setInterval(() => {
              _this.getUploadStatus()
            }, 60000)
          }
    },
    
    
    // 上传失败的回调
    handleError(response, file, fileList) {
          console.log('error-----------')
          console.log(response)
          this.isImporting = false
          this.$refs.upload.clearFiles()
    },

  • 相关阅读:
    今日进度
    今日进度
    每周总结
    今日进度
    今日进度
    今日进度
    flask展示Excel
    ubuntu 相关
    python解析xml三种方法【ElementTree】【DOM】【SAX】
    Lambda实现if...elif...else【三元表达式】
  • 原文地址:https://www.cnblogs.com/hahahakc/p/14187753.html
Copyright © 2011-2022 走看看