首页 > antdesign的Input控件加了初始化值,网站控制台暴警告,什么原因?

antdesign的Input控件加了初始化值,网站控制台暴警告,什么原因?


这句话爆了警告

即: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,就不会暴警告

为什么 呢?


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

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


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

【热门文章】
【热门文章】