1

我正在尝试为我的 RN 应用程序创建自定义卡片视图,现在我正在处理卡片的封面图像,但似乎图像容器溢出了主容器,这似乎是由与框阴影冲突引起的(在这里,我删除了我的样式)。

这是我的卡片组件的代码

export const LocationCard: React.FC<Props> = ({
  name,
  imageURI,
  description,
}) => {
  return (
    <View style={styles.card}>
      <View style={styles.imagecontainer}>
        <Image
          source={{ uri: imageURI }}
          style={{ width:"100%",height:"100%", borderRadius: 25, flexWrap:"wrap"}}
          resizeMode="cover"
        />
      </View>
      <View style={styles.content}>
        <Text>{name}</Text>
        <Text>{description}</Text>
      </View>
    </View>
  );
};

这是一张对比图

在此处输入图像描述

4

1 回答 1

0

您可以使用 => 溢出:'隐藏'

<View style={[styles.imagecontainer, {overflow: 'hidden'}]}>
  <Image
    source={{uri: imageURI}}
    style={{width: '100%', height: '100%', borderRadius: 25, flexWrap: 'wrap'}}
    resizeMode="cover"
  />
</View>;

于 2020-10-06T08:13:57.270 回答