小编you*_*n26的帖子

react-native:未设置宽度或高度时不显示图像

版本: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 = StyleSheet.create({
  container: {
    flex: 1
  },
  image: {
     flex: 1,
    resizeMode: 'contain'
  },
});
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-native-android

5
推荐指数
1
解决办法
2629
查看次数