点击提交上传文件
<el-upload
class="upload-demo"
multiple
ref="upload"
action=""
:on-preview="handlePreview"
:on-change="changeFiles"
:on-remove="handleRemove"
:file-list="fileList"
:auto-upload="false"
>
<el-button
slot="trigger"
size="small"
type="primary"
>选取文件</el-button
>
</el-upload>
handlePreview(file, fileList) {
},
changeFiles(file, fileList) {
this.fileFormat = "png,gif,jpg,jpeg,svg,tif,pdf";
let testmsgs = file.name.substring(file.name.lastIndexOf(".") + 1);
const extension = this.fileFormat.indexOf(testmsgs) > -1;
let bool = false;
if (extension) {
bool = true;
} else {
bool = false;
}
if (!extension) {
this.$message.warning(`上传文件只能是${this.fileFormat}格式!`);
this.$refs.upload.clearFiles();
return bool;
}else{
this.fileList = fileList;
}
},
handleRemove(file, fileList) {
},
submit(){
let orderHandle = new FormData();
for (var property in this.formData) {
orderHandle.append(property, this.formData[property]);
}
}