node.js - antdesign的Input控件加了初始化值,网站控制台暴警告,什么原因?
巴扎黑
巴扎黑 2017-04-17 14:45:12
0
2
688


这句话爆了警告

即:Warning: Input is changing an uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://fb.me/react-controlle...
如果,我在initailValue传入不变的量string,就不会暴警告

为什么 呢?

巴扎黑
巴扎黑

모든 응답(2)
PHPzhong

我也有这样的问题,因为只是warn不是error不影响开发就没管

巴扎黑

你报的错最后的那个链接中,有提到:A controlled <input> has a value prop。而你的代码中,并没有出现value属性。

而你将一个函数执行结果放入input中的作法,个人觉得不可取。你应事先以一个变量保存此函数的执行结果,再将变量放入input中,就如formItemLayout一样,我觉得这样更好

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!