検索

ホームページ  >  に質問  >  本文

node.js - 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,就不会暴警告

为什么 呢?

巴扎黑巴扎黑2865日前758

全員に返信(2)返信します

  • PHPz

    PHPz2017-04-17 14:47:12

    私もこの問題を抱えています。これはエラーではなく単なる警告であり、開発には影響しないため、気にしません。

    返事
    0
  • 巴扎黑

    巴扎黑2017-04-17 14:47:12

    あなたが報告したエラーの最後のリンクには、次のように記載されています。制御された <input> には value prop があります。コードには value 属性が表示されません。

    関数の実行結果を入力に入れることは、個人的には望ましくありません。 formItemLayoutと同じように、この関数の実行結果をあらかじめ変数に保存しておいて、その変数をinputに入れるのが良いと思います。

    返事
    0
  • キャンセル返事