我想并排显示两个图像,而不是在另一个图像的底部显示。这是我的代码:
<Content style={{flexDirection: 'row', flexWrap: 'wrap'}}>
<Image
key={data[0]['id']}
source={{ uri: data[0]['image']['url']}}
style={{
width: Dimensions.get('window').width * 0.2,
height: 120,
}}
/>
<Image
key={data[1]['id']}
source={{ uri: data[1]['image']['url']}}
style={{
width: Dimensions.get('window').width * 0.2,
height: 120,
}}
/>
</Content>
但它没有按预期工作。我在这里缺少什么?
最佳答案
Avoid flexWrap and use flex.
<Content style={{flexDirection: 'row', flex:1}}> // Note flex.
<Image
key={data[0]['id']}
source={{ uri: data[0]['image']['url']}}
style={{
flex: 0.5, // Give the 50% of the width to this image.
height: 120,
}}
/>
<Image
key={data[1]['id']}
source={{ uri: data[1]['image']['url']}}
style={{
flex: 0.5, // Give the 50% of the width to this image.
height: 120,
}}
/>
I haven't really tested this code. But it should work fine. Thanks.
关于ios - 内容上的 native 基本弯曲方向不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43580806/