react-native 中 textarea 的替代方案是什么? [英] What is an alternative of textarea in react-native?

查看:70
本文介绍了react-native 中 textarea 的替代方案是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有用于 react-native 的内置文本区域组件?我试图实现这些:

Is there any built in text area component for react-native? I have tried to implement these ones:

https://github.com/buildo/react-autosize-textarea

https://github.com/andreypopp/react-textarea-autosize

但收到错误期望组件类得到对象对象".

but getting an error "Expected a component class got object object".

推荐答案

是的.叫做TextInput,普通的TextInput组件支持多行.

Yes there is. It's called TextInput, the normal TextInput Component supports multiple lines.

只需将以下属性分配给您的 TextInput 组件

Just assign following properties to your TextInput Component

multiline = {true}
numberOfLines = {4}

最后你应该有这个:

<TextInput
    multiline={true}
    numberOfLines={4}
    onChangeText={(text) => this.setState({text})}
    value={this.state.text}/>

来源 https://facebook.github.io/react-native/docs/textinput

这篇关于react-native 中 textarea 的替代方案是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆