如何为React Native组件设置最小宽度或高度?
在css中,我可以使用min-width / min-height
https://facebook.github.io/react-native/docs/flexbox.html#content
react-native docs上没有minWidth / minHeight
从
iOS和
Android的react-native版本0.29.0开始支持minHeight,maxHeight,minWidth和maxWidth属性。
以下是react-native documentation中的maxHeight描述。此描述也适用于其他最小/最大样式属性。
maxHeight is the maximum height for this component,in
logical pixels.It works similarly to max-height in CSS,but in React Native you must
use points or percentages. Ems and other units are not supported.See 07003 for
more details.
一个虚拟的例子:
<View style={{ minWidth: '20%',maxWidth: 500,minHeight: '10%',maxHeight: 150,}} />