【问题标题】:Set initialValue formik设置初始值形式
【发布时间】:2020-07-19 10:29:25
【问题描述】:

我目前正在使用 formik 构建表单,但是当我在 initialValues 中使用嵌套对象时,如下所示: address:{title:"this a title",value:{principalAddress:"test",seconderyAddress:""}}

设置字段名称时,我无法访问formik字段中的principalAdress

<Field component={TextField} fullWidth type="text" name="value. seconderyAddress"/>.

如果有人可以帮助我,我将不胜感激。

【问题讨论】:

  • 请分享你的整个initialValues对象
  • @thedude 我分享它。

标签: reactjs material-ui formik formik-material-ui


【解决方案1】:

尝试将字段名称设置为:address.value.principalAddress

<Field component={TextField} fullWidth type="text" name="address.value.principalAddress"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-19
    • 1970-01-01
    • 2017-07-31
    • 1970-01-01
    • 1970-01-01
    • 2019-01-23
    相关资源
    最近更新 更多