initialValue: formData.orderInfo ? formData.orderInfo.netWtUnits : 'MT',
onChange: e => this.handleUnitsChange(e, 'orderInfo.netWtUnits'),
rules: [
{
required: this.props.contract=="No"?true:false,
message: 'Please input Weight Units!'
}
]
})(
<Select placeholder="MT" style={{ width: 55 }}>
<Select.Option value="MT">MT</Select.Option>
<Select.Option value="KG">KG</Select.Option>
</Select>
);
我要为此添加默认值。请您帮忙
答案 0 :(得分:0)
使用defaultValue
属性
<Select defaultValue="MT"/>
重量选项示例:
const weightOptions = ["MT", "KG"];
const addWeightOptions = weightOptions =>
weightOptions.map((weight, i) => (
<Select.Option key={`${weight}-${i}`} value={weight}>
{weight}
</Select.Option>
));
<Select
placeholder="Select Weight Units"
defaultValue={weightOptions[0]}
>
{addWeightOptions(weightOptions)}
</Select>