0

我对 Android 上的 react-native-swiper 有问题。相同的代码适用于 iOS!

下面是正在发生的事情的图像:

在此处输入图像描述

蓝色区域应该是一个正方形,所有图像都应该在其中。像这样的东西(我在这里只渲染一张图片):

在此处输入图像描述

这就是我的代码的样子:

    renderSwiper = () => {
        const images = this.props.data.item[1].images;
        let swiperImages = images.map((image, index) => {
            let priority = FastImage.priority.normal;
            if (index === 0)
                priority = FastImage.priority.high;
            return (
                <TouchableWithoutFeedback key={index} onPress={this.routeToListingDetails} >
                    <FastImage
                        style={styles.imageStyle}
                        source={{uri: image, priority: priority}}
                    />
                </TouchableWithoutFeedback>
            )
        })
        return (
            <View style={{ aspectRatio: 1, width: '100%'}}>
                <Swiper 
                    loop={false} 
                    paginationStyle={styles.swiperPaginationStyle}
                >
                    {swiperImages}
                </Swiper>
            </View>
        );
    }

    render(){
        return (
            <View style={styles.container} >

                <View style={{ borderColor: 'blue', borderWidth: 2 }}>
                    {this.renderSwiper()}
                </View>

            </View>
        )
    }

const styles = StyleSheet.create({
    container:{
        width:'50%',
        alignItems:'center',
        marginBottom:'4%',
        padding:'2%',
    },
    imageStyle:{
        resizeMode: "cover",
        width: "100%",
        aspectRatio:1
    }
})
4

0 回答 0