React Native 限制 TextInput 中的行 [英] React Native to limit lines in TextInput
本文介绍了React Native 限制 TextInput 中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果设置 multiline 为 true,React Native 将接受 TextInput 中的无限行数,有 maxLength 但它只是限制了最大字符数,那么如何在 TextInput 上设置最大行数?
If set multiline as true, React Native will accept unlimited lines in TextInput, there has maxLength but it just limits the maximum number of characters, so how to set maximum lines on TextInput?
推荐答案
你可以使用 maxHeight
和 minHeight
来接受你想要的.对于标准文本 fontSize,给 maxHeight={60}
将使 TextInput 在 3 行后可滚动.这对 IOS 很有用 - 对于 Android,您可以使用 numberOfLines
属性.
You can use maxHeight
and minHeight
to accept what you want. For standard text fontSize, giving maxHeight={60}
will make TextInput scrollable after 3 lines. This is good for IOS - for Android you can use numberOfLines
prop.
这篇关于React Native 限制 TextInput 中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文