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


这句话爆了警告

即: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 has a value prop。而在你的程式碼中,並沒有出現value屬性。

而你將一個函數執行結果放入input中的作法,個人覺得不可取。你應事先以一個變數儲存此函數的執行結果,再將變數放入input中,就如formItemLayout一樣,我覺得這樣比較好

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!