我有一个TextInput
,如下所示,
<TextInput
style={{borderWidth: 1, borderColor: "#dedede", width: '90%', marginTop: 20, borderRadius: 1}}
placeholder={'Tell us more about our service'}
multiline = {true}
numberOfLines = {10}
value={this.state.customerFeedback}
onChangeText={customerFeedback => this.setState({ customerFeedback })}
underlineColorAndroid="transparent"
/>
因为我输入了numberOfLines = {10}
,所以如果我键入10行以上,则必须在TextInput
区域内滚动文本。但就我而言,TextInput
的大小逐渐增加,如下图所示,
[如果我们查看TextInput
,则有10行以上。
[有人可以让我知道如何根据TextInput
道具限制numberOfLines
区域吗?谢谢。
您唯一缺少的是textInput中样式的maxHeight属性,我已添加maxHeight:50
:
<TextInput
style={{borderWidth: 1, borderColor: "#dedede", width: '90%', marginTop: 20, borderRadius: 1,maxHeight:50}}
placeholder={'Tell us more about our service'}
multiline = {true}
numberOfLines = {10}
value={this.state.customerFeedback}
onChangeText={customerFeedback => this.setState({ customerFeedback })}
underlineColorAndroid="transparent"
/>
尝试一次,并检查博览会小吃expo-snack
希望有帮助。如有疑问,请随时
我看到了您的代码,一件事是您缺少样式的另一个属性maxHeight。我现在将其添加到您的代码中,现在您可以将该代码复制并粘贴到您的项目中。
{/*maxHeight:200 */}
<TextInput
style={{borderWidth: 1, borderColor: "#dedede", width: '90%', marginTop: 20, borderRadius: 1,maxHeight:200}}
placeholder={'Tell us more about our service'}
multiline = {true}
numberOfLines = {10}
value={this.state.customerFeedback}
onChangeText={customerFeedback => this.setState({ customerFeedback })}
underlineColorAndroid="transparent"
/>
我希望这会有所帮助:)