element 上傳文件 文件列表只顯示最新的一條


上傳操作 :

 

      <el-upload
        multiple
        accept=".rar,.zip,.doc,.pdf,.docx"
        class="upload-demo"
        thumbnail-mode
        :on-change="handleChange"
        action
        :file-list="fileList"
        :show-file-list="true"
        :http-request="uploadfile"
        >
        <el-button size="small" type="primary" class="upload">上傳審稿模板</el-button>
<!--        <div slot="tip" class="el-upload__tip">支持格式:.rar .zip .doc .docx .pdf,單個文件不能超過20MB。</div>-->
      </el-upload>

上傳函數:

// 上傳附件
      uploadfile(file){
        let formData = new FormData()
        formData.append("file", file.file)
//
updatetemplate 是接口
updatetemplate(formData).then( res => { if(res.data.code == 0){ this.$message.success("上傳成功") } }) },

上傳函數時列表操作 :刪除掉之前的

   handleChange(file, fileList) {
        this.fileList = fileList.slice(-1);
      },

 


免責聲明!

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



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