【问题标题】:Using NativeBase textArea in react native在本机反应中使用 NativeBase textArea
【发布时间】:2019-12-30 22:32:15
【问题描述】:

您好,我想要一个 textArea 以便让用户在我的应用中发送评论消息。那么如何检索用户使用 this 组件编写的消息呢?

  render() {
    return (
      <Container>
        <Content padder>
            <Item style = {{ marginBottom: 10}}>
                <Input placeholder="Email" />
            </Item>
            <Form style = {{ marginBottom: 20}}>
                <Textarea rowSpan={3} bordered placeholder="Votre message" />
            </Form>
            <Button success>
                <Text>Envoyer</Text>
            </Button>
        </Content>

      </Container>

    );
  }

我希望能够获取用户的电子邮件和消息。谢谢 !

【问题讨论】:

    标签: react-native native-base


    【解决方案1】:

    原生基础输入是 react-native TextInput 组件的扩展,这就是您可以使用 onChangeText 事件的原因。 对于您的示例,假设我们的状态中有两个元素,电子邮件和消息。 {email: "", message: ""}

    我们需要为两个输入添加一个 onChangeText 事件,如下所示:

    <Input placeholder="Email" onChangeText={email => this.setState({email: email})} />
    

     <Textarea rowSpan={3} bordered placeholder="Votre message" onChangeText={message=> this.setState({message: message})} />
    

    现在您可以使用this.state.emailthis.state.message 检索用户编写的文本

    请在React-native TextInputHandling Text Input 的官方 react-native 文档中阅读有关处理文本输入的更多信息

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-30
      • 1970-01-01
      • 1970-01-01
      • 2020-06-12
      • 2017-10-30
      • 1970-01-01
      • 2023-03-04
      • 2015-11-22
      相关资源
      最近更新 更多