简体   繁体   English

antd 图片上传 需要将基于 class 的组件转换成 react -hooks 无法增加图片的宽高

[英]antd image upload Need to convert class based component into react -hooks and unable to increase the width and height of image

I am facing this issue.我正面临这个问题。 I have attached the code and error and CodeSandbox link.我附上了代码和错误以及 CodeSandbox 链接。

Tried to fix the issue in various methods and ways but it's not fixing.试图以各种方法和方式解决问题,但没有解决。 I am not able to know why it's getting an error I don't understand the exact issue in the code.我不知道为什么会出现错误我不明白代码中的确切问题。 Could anyone help with the solution?任何人都可以帮助解决问题吗?

https://codesandbox.io/s/infallible-darkness-g1ge3 https://codesandbox.io/s/infallible-darkness-g1ge3

I think I got it to work: https://codesandbox.io/s/hungry-forest-dur6r我想我让它工作了: https://codesandbox.io/s/hungry-forest-dur6r

there were many small errors, you might want to compare with your original code to figure it out by yourself:)有很多小错误,您可能想与您的原始代码进行比较以自己解决:)

@berin @berin

Can u help to try that method using this method: https://github.com/JakeHartnell/react-images-upload你能帮我试试这个方法吗:https://github.com/JakeHartnell/react-images-upload

Need to follow this pattern需要遵循这个模式

The image url in index zero of that array is the primary image.该数组的索引零中的图像 url 是主图像。

Use a drag and drop React lib to sort the images (your choice on the React lib)使用拖放 React 库对图像进行排序(您在 React 库中选择)

In regards to the UI, an 'add image' button should be displayed if there are less than four images.关于 UI,如果图像少于四个,则应显示“添加图像”按钮。

There should be a delete icon overlay on each image so that a user could remove an image.每个图像上都应该有一个删除图标覆盖,以便用户可以删除图像。 hi this need to be achived using嗨,这需要使用图片检查一下

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM