有没有办法在蚂蚁设计的选择选项上设置默认值?

时间:2021-06-10 11:18:14

标签: reactjs

我在使用 ant design 在选择选项中设置默认值时遇到问题。现在,当我设置 defaultValue 并单击提交按钮时,默认值未定义。我尝试了 getFieldDecorator,但它已经折旧了,不再工作了。

问题:有什么解决方案或方法可以用来解决这个 defaultValue?

这是我的选择:

    <Form.Item name="bank_name" label="Bank Name" rules={[
    {
        required: true,
        message: 'Please input Bank Name'
    }
    
]}>
    <Select
        showSearch
        placeholder="Select bank"
        optionFilterProp="children"
        className="form-control"
        defaultValue={selected_items.bank_id}
        style={{color: 'white'}}
    >
        {bank_items.map((option) => (
            <Option key={option.id} value={option.id}>{option.bank_name}</Option>
        ))}
    </Select>
</Form.Item>

错误:

Error

0 个答案:

没有答案