<input ref="excel" type="file" name="file" hidden @change="changeFile">
<el-button type="primary" @click="uploadFile">上传</el-button>
changeFile() {
const file = this.$refs.excel.files[0]
const suffix = file.name.substring(file.name.lastIndexOf('.'))
const isLt50M = file.size / 1024 / 1024 < 50
if (suffix !== '.xls' && suffix !== '.xlsx') {
this.$message.error('只支持xls格式Excel文件!')
return
}
if (!isLt50M) {
this.$message.error('Excel文件大小不能超过 50MB!')
return
}
const data = new FormData()
data.append('file', file)
}