首页 > 解决方案 > React Native:弹性与高度

问题描述

我是 React Native 的新手。

我看到了一个类似的问题,但它没有回答我在寻找什么。

我的问题是,有什么区别(性能,行为):

<View style={{ flex: 1, background: 'blue' }}>
   <Text style={{ flex: 0.8, background: 'red' }}>Hello</Text>
   <Text style={{ flex: 0.2, background: 'brown' }}>World</Text>
</View>

<View style={{ height: '100%', background: 'blue' }}>
   <Text style={{ height: '80%', background: 'red' }}>Hello</Text>
   <Text style={{ height: '20%', background: 'brown' }}>World</Text>
</View>

因为我看不出使用两者有什么区别。

标签: reactjsreact-native

解决方案


查看这篇文章 - 它与响应能力有关,而不是像素百分比。React Native:高度与弹性


推荐阅读