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()
    },

  • 相关阅读:
    网页中的JavaScript
    css颜色表示
    css文本属性
    css2选择器
    css3选择器
    Canvas练习
    Canvas
    CSS样式之语法
    css基础1
    php操作成功返回当前页并刷新
  • 原文地址:https://www.cnblogs.com/hahahakc/p/14187753.html
Copyright © 2011-2022 走看看