Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
515 views
in Technique[技术] by (71.8m points)

antd4上传图片时的剪裁工具不能用在表单的getFieldDecorator里面吗

背景:想在表单中使用antd4提供的Imgcrop上传并裁剪图片,使用后发现会报找不到refs,但是又不能改Imgcrop的源码,请问各位大佬有解决方法吗?


代码:

{getFieldDecorator('logo')(
    <ImgCrop>
      <Upload
        action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
        listType="picture-card"
      >
        上传
      </Upload>
    </ImgCrop>
)}

报错信息:

屏幕快照 2020-06-17 15.19.28.png

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

image.png

ImgCrop组件是否提供了valueonChange属性。

一般这种第三方的控件,都需要自己再封装一遍。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...