vue 使用elementui上傳文件到后台


     <el-upload
          class="upload-demo"
          ref="upload"
          action="http://192.168.1.4:8082/fanliorder/dealEleOrder/"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :on-success="handleSuccess"
          :file-list="fileList"
          :multiple="false"
          :limit="1"
          :auto-upload="false">
        <el-button slot="trigger" size="small" type="primary">選取文件</el-button>
        <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload($event)">上傳到服務器</el-button>
        <div slot="tip" class="el-upload__tip">只能上傳execl文件,且不超過500kb</div>
      </el-upload>

 

data

fileList: [],

 

methods

// 成功上傳到服務器后返回的內容
    handleSuccess(e) {
      console.log('上傳成功,能哪都澳門嗎', e)
      this.$message(e.message);
    },
    // 上傳文件到服務器
    submitUpload(e) {
      console.log('我要上傳了', e)
      this.$refs.upload.submit();

    },
    // 刪除文件
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM