Skip to content

Upload组件与Form组件结合有问题 #925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
luichooy opened this issue Jul 2, 2019 · 1 comment
Closed
1 task

Upload组件与Form组件结合有问题 #925

luichooy opened this issue Jul 2, 2019 · 1 comment
Labels

Comments

@luichooy
Copy link

luichooy commented Jul 2, 2019

  • 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

  1. 在Form组件内部使用Upload组件使用v-decorator="['dragger', { valuePropName: 'fileList', getValueFromEvent: normFile, }]"
  2. 选择一张图片后,然后调用 this.form.resetFields()
  3. 然后重新选择图片
  4. 报错

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

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant