<el-button
class="correct-button"
>
<el-upload
action="#"
:show-file-list="false"
:file-list="fileList"
:http-request="httpRequest"
>
<i class="iconfont icon-icon-daoru"></i>
<span>导入</span>
</el-upload>
</el-button>
data() {
return {
fileList: [],
};
httpRequest(files) {
const fd = new FormData();
fd.append('file', files.file);
importData(fd).then((res) => {
if (res.code === '00000') {
this.$message.success('导入成功');
} else {
this.$message.error('导入失败');
}
});
},
import ajax from 'axios';
export const importData= (data) => ajax({
method: 'post',
url: 你的url,
headers: {
'Content-Type': 'multipart/form-data',
},
data,
});
|