Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

antd FormItem 如何设置多个属性的值

问题描述

大家肯定都用过form组件,当其中的FormItem用的是Select时一般都会是Key和Value的。
比如这段代码:


<FormItem label="组类型:" hasFeedback {...formItemLayout}>
  {getFieldDecorator('GroupTypeID', {
    initialValue: item && item.GroupTypeID,
    rules: [
      {
        required: true,
        message: '组类型未选择',
      },
    ]
  })(
    <Select
      placeholder="请选择组类型"
      onSelect={(a, b) => this.onGroupTypeChanged(a, b)}>
      {groupTypes.map((gt, index) => {
        return (<Option key={gt.id + 'GT'} value={gt.id}>
          {gt.GroupTypeName}</Option>);
      })}
    </Select>
    )}
</FormItem>


默认情况下只给Item的GroupTypeID对象设置了下面Select组件的value中的值。

但我是想设置多个值,比如GroupTypeID、GroupTypeName。
有没有一个优雅的办法可以设置?

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

大兄弟,你这个是怎么解决了?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...