上传前校验,校验通过,上传弹框出现
el-upload使用了:disabled="uploadDisableds"
在data中定义uploadDisableds: false
<el-upload ref="upload" :action="actionUpload" :data="uploadForm" :headers="headers" :on-success="handleSuccess" :on-error="handleError" :limit="10" :before-upload="beforeUpload"
:file-list="fileList" :disabled="uploadDisableds" :show-file-list="false" :on-progress="handleProgress" class="upload-demo" multiple accept=".xls,.xlsx">
<el-button slot="trigger" size="small" type="primary" @click="handleUploadSheet">上传工资表</el-button>
<!-- @click="handleUploadSheet" :on-preview="handlePreview" :on-remove="handleRemove" -->
</el-upload>
在methods中使用
handleUploadSheet() {
this.$refs['uploadForm'].validate((valid) => {
if (valid) {
this.uploadDisableds = false
// this.$refs.upload.submit()
} else {
this.uploadDisableds = true
}
})
},