1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > antd表单设置默认值

antd表单设置默认值

时间:2018-09-13 17:25:32

相关推荐

antd表单设置默认值

在下面这个地方设置

<Form.Item>{getFieldDecorator('username', {//这个地方initialValue:'Tom',rules: [{required: true, message: '请输入你的用户名!'}],})(<Inputprefix={<Icon type="user" style={{color: 'rgba(0,0,0,.25)' }} />}placeholder="Username"/>,)}</Form.Item>

注意antd表单设置默认值位置

方法二setFieldsValue

设置一组输入控件的值(注意:不要在 componentWillReceiveProps 内使用,否则会导致死循环,原因)

(/ant-design/ant-design/issues/2985)

this.props.form.setFieldsValue({username:"我是初始值"});

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。