【问题标题】:Is there a way to make a dynamic text area in react有没有办法在反应中制作动态文本区域
【发布时间】:2021-02-09 03:08:19
【问题描述】:

我正在玩 React Components,我偶然发现了这个网站,其中介绍了使用带有引导样式的 Form Control 的不同方法。我想创建一个文本区域,当用户按下回车键时,它的大小会动态变化,但在下面的练习中会添加一个滚动条。我可以只更改行数,但是有没有办法让每次用户创建新行时文本字段的大小都发生变化

  <Form.Group controlId="exampleForm.ControlTextarea1">
    <Form.Label>Example textarea</Form.Label>
    <Form.Control as="textarea" rows={1} />
  </Form.Group>

React bootstrap examples

感谢您的宝贵时间和回答

【问题讨论】:

标签: reactjs textarea react-bootstrap form-control


【解决方案1】:

此包将具有您正在寻找的行为:react-textarea-autosize

为了使其类似于引导程序,我建议向此组件添加引导 css 类名 (more info):

<TextareaAutosize className="form-control" />

【讨论】:

    猜你喜欢
    • 2022-10-01
    • 2012-06-20
    • 2011-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-21
    相关资源
    最近更新 更多