导入文件的写法
1.
<el-button type="" @click="upload">导入学员</el-button>
2.
upload(){
this.$refs['files'].click()
}
3.
<input
style="display: none"
ref="files"
@change="uploadExcelFile"
type="file"
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
/>
4.
uploadExcelFile(e) {
const file = e.target.files[0]
if (!this.checkFile(file)) return
const formData = new FormData()
formData.append('file', file)
this.uploading = true
uploadExamUsers(this.examValue,formData)
.then(() => {
this.$message.success('导入成功')
this.getExamineeByPage()
})
.catch(() => {
})
},