-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
Description
- I have searched the issues of this repository and believe that this is not a duplicate.
Version
1.3.8
Environment
vue2.6.6
Reproduction link
https://vue.ant.design/components/form-cn/#components-form-demo-other-form-controls
Steps to reproduce
- 在Form组件内部使用Upload组件使用
v-decorator="['dragger', { valuePropName: 'fileList', getValueFromEvent: normFile, }]" - 选择一张图片后,然后调用 this.form.resetFields()
- 然后重新选择图片
- 报错
What is expected?
修复
What is actually happening?
此情况下源码
reBeforeUpload(file, fileList) {
if (!this.beforeUpload) {
return true;
}
const result = this.beforeUpload(file, fileList);
if (result === false) {
this.onChange({
file,
fileList: uniqBy(this.sFileList.concat(fileList.map(fileToObject)), item => item.uid),
});
return false;
} else if (result && result.then) {
return result;
}
return true;
},
中concat处报错。
原因是 form.resetFields() 将 fileList 置为 undefined, 而源码中又watch了 fileList,从而导致 sFileList 变为 undefined