Reactjs 反应本机:未设置宽度或高度时不显示图像
注册护士版本:0.38 只需使用flex指定图像样式,无宽度和高度,但图像不会显示在移动屏幕上。如何做到这一点Reactjs 反应本机:未设置宽度或高度时不显示图像,reactjs,react-native,react-native-android,Reactjs,React Native,React Native Android,注册护士版本:0.38 只需使用flex指定图像样式,无宽度和高度,但图像不会显示在移动屏幕上。如何做到这一点 <View style={styles.container}> <Image style={styles.image} source={{uri : 'https://www.baidu.com/img/bd_logo1.png'}}> </Image> </View> const styles = StyleShe
<View style={styles.container}>
<Image style={styles.image} source={{uri : 'https://www.baidu.com/img/bd_logo1.png'}}>
</Image>
</View>
const styles = StyleSheet.create({
container: {
flex: 1
},
image: {
flex: 1,
resizeMode: 'contain'
},
});
const styles=StyleSheet.create({
容器:{
弹性:1
},
图片:{
弹性:1,
resizeMode:“包含”
},
});
网络图像要求您设置高度/宽度样式的道具
您将在应用程序中显示的许多图像将不可用
在编译时,或者您希望动态加载一些以保持
二进制大小减小。与静态资源不同,您需要
手动指定图像的尺寸
//很好
//坏的
试试图片:{flex:1,width:null,height:null}
看看样式。是的,谢谢。但是如何实现Pinterest布局呢。如何获取父元素宽度而不是窗口?2.如何在使用<代码> ResiZeMod <代码>之后保留空白空间?非常感谢你可以使用API来获取窗口的高度/宽度,并根据多少行/单元格手动计算图像大小等。
// GOOD
<Image source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}}
style={{width: 400, height: 400}} />
// BAD
<Image source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}} />