【问题标题】:React Native resizeMode:'contain' not working with expo?React Native resizeMode:'contain'不适用于expo?
【发布时间】:2020-04-07 13:38:44
【问题描述】:

我正在使用resizeMode:'contain',因为图像正在拉伸。但 resizeMode 不适用于 expo 应用程序。

image: {
    width: 80,
    height: 80,
    borderRadius: 10,
    resizeMode:'contain',
  },


<TouchableOpacity onPress={() => onPress({ product })}>
   <Image
     source={{ uri: getProductImage(product.images[0].src, 100) }}
     style={styles.image}
   />
</TouchableOpacity>[enter image description here][1]

screenshot

【问题讨论】:

标签: react-native expo react-native-stylesheet


【解决方案1】:

尝试将resizeMode='contain' 放入Image 组件中:

<Image
     resizeMode='contain'
     source={{ uri: getProductImage(product.images[0].src, 100) }}
     style={styles.image}
   />

使用flex 和`height:undefined' 来检查这个方法: example

【讨论】:

  • 我像这样使用了 resizeMode={'contain'} 但还是不行。
  • 这样使用 resizeMode='contain'
  • 仍然无法使用是否有其他方法可以使用它。在此之前工作,但在更新 node_module 之后,该属性不起作用。
  • 查看示例中的 flex 方法
  • 这很好,但我遇到了图像高度的问题。图片来自 API。
猜你喜欢
  • 1970-01-01
  • 2021-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多