react native Swiper-轮播图

github地址:
https://github.com/leecade/react-native-swiper

npm i react-native-swiper --save
使用:
} //未选中的圆点样式
    activeDot={} //选中的圆点样式
    paginationStyle={styles.swiper_pagination}>  //小圆点的位置
    {this.swiperChildrenView()}

样式:
  swiper_dot: {
        backgroundColor: 'rgba(0,0,0,.5)',
        width: 8,
        height: 8,
        borderRadius: 4,
        marginLeft: 3,
        marginRight: 3,
        marginTop: 3,
        marginBottom: 3,
    },
    swiper_activeDot: {
        backgroundColor: WhiteTextColor,
        width: 16,
        height: 2,
        borderRadius: 1,
        marginLeft: 2,
        marginRight: 2,
    },
注意 :

运行的时候会报错 Cannot read property 'x' of undefined


react native Swiper-轮播图_第1张图片
33.png
解决方案:

修改react-native-swiper下src/index.js

  static defaultProps = {
    horizontal: true,
    pagingEnabled: true,
    showsHorizontalScrollIndicator: false,
    showsVerticalScrollIndicator: false,
    bounces: false,
    scrollsToTop: false,
    removeClippedSubviews: true,
    automaticallyAdjustContentInsets: false,
    showsPagination: true,
    showsButtons: false,
    disableNextButton: false,
    loop: true,
    loadMinimal: false,
    loadMinimalSize: 1,
    autoplay: false,
    autoplayTimeout: 60, //默认2.5,改大一些
    autoplayDirection: true,
    index: 0,
    onIndexChanged: () => null
  }
react native Swiper-轮播图_第2张图片
44.png
效果:
react native Swiper-轮播图_第3张图片
22.png

你可能感兴趣的:(react native Swiper-轮播图)