当 multilne 时 React Native TextInput 自动增长 [英] React Native TextInput auto grow when multilne
本文介绍了当 multilne 时 React Native TextInput 自动增长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个 TextInput,当它有多行时可以自动增长.
I want to create a TextInput which can grow automatically when it has multilines.
<TextInput
placeholder="Type Comment"
value={this.state.comment.value}
onChangeText={value => this.onChangeComment(value)}
onPress={() => this.uploadComment()}
multiline={true}
maxLength={200}
numberOfLines={5}
/>
我怎样才能做到这一点?
How can I achieve this?
推荐答案
认为 React Native 团队在当前版本 (0.59) 中使用 multiline
道具修复了它.
Think that the React Native team fixed it in current version (0.59) with the multiline
prop.
这对我有用
<TextInput
style={{
width: '90%',
borderColor: 'gray',
borderWidth: 1,
padding: 2,
}}
multiline
onChangeText={text => this.setState({ text })}
value={this.state.text}
/>
这篇关于当 multilne 时 React Native TextInput 自动增长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文