【问题标题】:Giving an input a default value in redux-form以 redux-form 为输入提供默认值
【发布时间】:2017-06-03 13:14:06
【问题描述】:

我原以为这很容易......但我正在努力:D

    <Field type="text" component="input" value="jamie" name="email" placeholder="Enter email address"/>
    <Field type="text" component="input" defaultValue="jamie" name="email" placeholder="Enter email address"/>
    <Field type="text" component="input" format="jamie" name="email" placeholder="Enter email address"/>

我就是买不到。

【问题讨论】:

    标签: javascript reactjs redux redux-form


    【解决方案1】:

    在课堂外定义initialValues

    const initialValues = {
      email: 'example@gmail.com'
    }
    

    并把初始值放在这里

    export default reduxForm({
      form: 'venues',  // a unique identifier for this form
      destroyOnUnmount: true,
      validate,
      initialValue
    })(VenueComponent)
    

    【讨论】:

    • 啊非常好!谢谢芽。现在我只需要弄清楚如何从道具中获取值
    • @JamieHutber 嘿,你知道怎么做吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多