this.file = ""
this.fileName = ""
this.dsCode = ""
this.uploadUrl = 接口地址 + '?masterCode=' + this.dsCode //拼接额外参数
util.ajax = axios.create({
url: util.BaseURL,
timeout: 30000
});
handleFileChange (file) {
let inputDOM = this.$refs.inputer;
// 通过DOM取文件数据
this.file = inputDOM.files[0];
this.fileName = this.file.name;
const filesType = this.file.name.split('.')[1] === 'xls' //判断文件格式
const filesType2 = this.file.name.split('.')[1] === 'xlsx' //判断文件格式
let fileFormData = new FormData(); //使用formData 提交
fileFormData.append('file', this.file);
},
//ajax
util.ajax({
method: "post",
url: this.uploadUrl,
data: this.fileFormData
}).then(res => {
});