react-native - 在本机反应中使用 NativeBase textArea
问题描述
嗨所以我想要一个 textArea 以便让用户在我的应用程序中发送评论消息。那么如何检索用户使用此组件编写的消息呢?
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>
);
}
我希望能够获得用户的电子邮件和消息。谢谢 !
解决方案
Native-base 输入是 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.email
和检索用户编写的文本this.state.message
请在React-native TextInput和处理文本输入的官方 react-native 文档中阅读有关处理文本输入的更多信息
推荐阅读
- javascript - 添加移动外形尺寸后,加载项在最新版本的 Outlook for Mac 上消失
- php - Cloudflare 安全级别不会从 api 改变
- java - 如何知道excel是否受密码保护
- tfs - TFS 2018 - 构建预发布包
- plsql - plsql 日期到毫秒数
- javascript - Telerik Kendo 网格从模板中获取行详细信息
- html - 带有 CSS 的 HTML 元素位置
- google-chrome - Firefox 中是否有相当于 Google Chrome 的 allow-insecure-localhost 标志?
- java - 无法从 IPA 读取 PNG
- vuejs2 - 带有 vuejs 的静态文件夹中的图像数组