在表单中验证upload,当文件被删除后,form并没有验证到
解决:
//vue
<a-upload
name="peoplefile"
:fileList="excelList"
:beforeUpload="beforeUpload"
@change="fileChange"
v-decorator="[
'file',
{
getValueFromEvent: normFile,
rules: [{ required: true, message: $t('addm.agreefile') }]
}
]"
>
//方法
normFile(e) {
if (Array.isArray(e)) {
return e;
}
return e && e.fileList;
},
转载:https://blog.youkuaiyun.com/qq_32674347/article/details/105427805
本文介绍在Vue项目中如何处理表单文件上传的验证问题,特别是当文件被删除后,表单验证未能及时更新的情况。通过使用自定义验证方法和监听文件列表变化,确保上传组件与表单验证同步。
4551





