使用element-ui中的el-upload組件時攜帶其他參數


<el-upload
        class="upload-demo"
        ref="upload"  
        :action="uploadURL+'/customer/excel'"   //后台接口(接受上傳的文件並做后端的邏輯處理)
        :headers="headers"
        accept=".xlsx,.xls"  // 限制文件格式
        :on-preview="handlePreview"
        :on-remove="handleRemove"
        :on-success="handleSuccess" //上傳文件成功時的回調函數
        :file-list="fileList"
        :limit="1"  // 限制文件個數
        :data="uploadData"   //上傳文件時要上傳的額外參數
        :on-exceed="handleExceed"
        :auto-upload="false">  //停止文件自動上傳模式
        <el-button slot="trigger" size="small" type="primary">選取文件</el-button>
 </el-upload>

 data中

export default {
 data() {
    uploadData:{name: this.$parent.name}  
    // name為java后台需要接收的數據,
this.$parent.name則是獲取父組件的name
  } 
}

 


免責聲明!

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



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