Skip to content
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

fix: (ImageUploader) change the deleted logic to delete images by index #4494

Merged
merged 1 commit into from
Dec 3, 2021

Conversation

liu-zhi-fei
Copy link
Contributor

fix #4328
我发现删除图片是通过url,相同url图片就会出现BUG。

现在通过index删除。

@@ -180,7 +180,7 @@ export const ImageUploader: FC<ImageUploaderProps> = p => {
onDelete={async () => {
const canDelete = await props.onDelete?.(fileItem)
if (canDelete === false) return
setValue(value.filter(x => x.url !== fileItem.url))
setValue(value.filter((x, i) => i !== index))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不如直接用 splice?

Suggested change
setValue(value.filter((x, i) => i !== index))
setValue([...value].splice(i, 1))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也可以,但是那样得写3行代码,splice的返回值是移除项组成的数组。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get,那按你的来

@awmleer awmleer merged commit bda0005 into ant-design:master Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

图片上传组件上传了2张一样的图片 删除和预览的时候会有问题
2 participants