antd form initialValue设置,我有一个判断,来确定渲染的组件,但是我只想给某一个组件设置初始值
<FormItem
{...formItemLayout}
label="目的地址"
hasFeedback
>
<Col span="7">
<Col span="20">
<Select defaultValue={`all`} placeholder="请选择" onChange={(val) => { this.handleTargetChange(val) }}>
<Option value="custom">自定义</Option>
<Option value="all">所有</Option>
</Select>
</Col>
<Col span="1"></Col>
</Col>
{
getFieldDecorator('mude', {
rules: [{ required: true, message: '目的地址不能为空!' }],
initialValue: this.state.isCustom ? '' : 'default'
})(
this.state.isCustom ?
<Col span="17">
<Col span="16">
<Input placeholder='请输入目的地址' />
</Col>
<Col span="1"></Col>
<Col span="1">/</Col>
<Col span="5">
<Input placeholder='' />
</Col>
</Col>
:
<Col span="14">
<Col span="20">
<Input placeholder='请输入目的地址' disabled={true} />
</Col>
</Col>
)
}
</FormItem>
我试过了这样:initialValue: this.state.isCustom ? '' : 'default'
没有效果,还有什么办法可以做到
this.state这样写是不能读到state的值的啊