美文网首页React
antd select如何支持既能输入不存在的选项又能进行下拉框

antd select如何支持既能输入不存在的选项又能进行下拉框

作者: 这样就好_yang | 来源:发表于2019-07-29 15:24 被阅读2次

主要是要设置:
mode='combobox'
optionLabelProp='children'

  <Form onSubmit={this.handleSubmit}>
    <FormItem
        style={{ marginBottom: 16 }}
        label="原因"
    >
        {getFieldDecorator('reason', {
            rules: [{
                required: true, message: '请选择替诊原因!',
            }],
        })(
            <Select
                style={{ width: '100%' }}
                placeholder="请选择替诊原因"
                loading={false}
                showSearch
                filterOption={this.filterOption}
                mode='combobox' 
                optionLabelProp='children'
            >
                {
                    this.state.reasonList.map((item, index) => {
                        return (
                            <Option key={item}>{item}</Option>
                        )
                    }) 
                }
            </Select>
        )}
    </FormItem>
    <FormItem  style={{ marginBottom: 16 }} >
        <Button onClick={hideStopModal}>取消</Button>
        <Button type="primary" htmlType="submit" className="login-form-button" style={{ marginLeft: 20 }}>确定</Button>
    </FormItem>
</Form> 

相关文章

网友评论

    本文标题:antd select如何支持既能输入不存在的选项又能进行下拉框

    本文链接:https://www.haomeiwen.com/subject/cbmbrctx.html