在响应本机中使用NativeBase textArea

问题描述 投票:0回答:1

[嗨,我想拥有一个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个回答
1
投票

基于本机的输入是对本机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中的官方反应本地文档中阅读有关处理文本输入的更多信息,>

© www.soinside.com 2019 - 2024. All rights reserved.