<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
}
}