【问题标题】:Set Antd TextArea value to Tag component将 Antd TextArea 值设置为 Tag 组件
【发布时间】:2019-04-30 09:50:09
【问题描述】:

我有 reactjs Antd 表单,我想在 TextArea 中渲染 Tag 组件,类似于 Select 组件!

我尝试设置值

values.description = <Tag color="magenta">magenta</Tag>
this.props.form.setFieldsValue(values);

函数但它显示 [object Object] []2

<Form.Item label={<span>Description</span>}>
    {getFieldDecorator('description', {
                                  initialValue:''
                                   })(
   <TextArea maxLength={500} autosize={{ minRows: 4, maxRows: 4 }} 
                     placeholder={'Description'} />
                                    )}
 </Form.Item>

我希望得到与 Select 组件 Antd Select Component 相同的结果 关于如何做到这一点的任何想法?

【问题讨论】:

标签: javascript reactjs antd


【解决方案1】:

TextArea 无法做到这一点。您正在寻找的是一个content editable div,这很容易做到:

<div contenteditable="true">
  <Tag color="magenta">magenta</Tag>
</div>

【讨论】:

  • 您能否提供一些关于如何在表单提交时设置值和取值的指导?
  • 我使用 并更改了一些 css &lt;Select mode="tags" tokenSeparators={[',']} size={'default'} size={'default'} dropdownStyle={{ display: 'none' }} style={{ width: '100%' }} &gt; &lt;/Select&gt;
猜你喜欢
  • 2021-12-08
  • 2019-10-20
  • 2020-06-09
  • 2011-12-16
  • 1970-01-01
  • 2021-08-04
  • 1970-01-01
  • 2016-05-07
  • 1970-01-01
相关资源
最近更新 更多