【发布时间】:2017-06-07 12:32:40
【问题描述】:
在 React-Native 中,是否可以在不声明 width 和 height 内 style 属性的情况下显示图像?
我希望图像占据它拥有的所有空间或以其实际尺寸呈现。 (例如resizeMode是否设置为cover。)
我阅读了这篇文章并尝试实现它的方法但没有成功:https://medium.com/the-react-native-log/tips-for-react-native-images-or-saying-goodbye-to-trial-and-error-b2baaf0a1a4d
这是我的代码:
<View>
<Image
source={{ uri: 'https://upload.wikimedia.org/wikipedia/en/c/c8/Marvelwolverine.jpg' }}
style={{
flex: 1,
height: undefined,
width: undefined,
}}
/>
</View>
但除非我指定硬编码 width 和 height,否则不会打印任何内容。
【问题讨论】:
标签: image react-native react-native-flexbox