本文主要是介绍vue el-upload 文件导入,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<el-upload class="upload-idCardFile"action="接口地址":headers="headers":on-success="handleUpLoadIdcardFile":on-error="handleUploadIdcardFail":before-upload="beforeUpload"accept=".xls,.xlsx":data="{额外参数: 额外参数}":show-file-list="false"><el-button class="identify-btn" size="small" type="primary">导入</el-button></el-upload>
headers: {token: 'ererefedgergrdfdfdf'}
// 上传文件失败handleUploadIdcardFail(res) {this.$message({type: 'info',message: res.msg})},// 上传文件成功handleUpLoadIdcardFile(res) {if (res.code === 200) {this.$message({type: 'success',message: '上传成功'})// 对数据做处理})}if (res.code === 405) {this.$message({type: 'warning',message: res.msg})}},// 批量导入证件beforeUpload (e) {const xlsx = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'const xls = 'application/vnd.ms-excel'if (e.type === xls) {return true} else if (e.type === xlsx) {return true} else {this.$message({type: 'warning',message: '上传文件类型不匹配'})return false}},
这篇关于vue el-upload 文件导入的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!