• swiper加载动态加载网络数据后,不能正常轮播,循环;reacrNative中使用reactnativeswiper


    reacrNative中使用react-native-swiper
    swiper加载本地的list数据时,没有问题;
    swiper加载动态加载网络数据后,不能正常轮播,循环;
    代码如下:


    //轮播图
    renderImageList() {
    let {indexHelpVideoList} = this.state;
    return (
    <View style={styles.imageListView}>
    {indexHelpVideoList && <Swiper
    ref={ref => this.imageListSwiper = ref}
    loop={true}
    autoplay={true}
    paginationStyle={{bottom: 4}}
    autoplayTimeout={3}
    >
    {indexHelpVideoList && indexHelpVideoList.map((item, index) => {
    return (
    <View key={item.id}>
    <Image style={styles.ListImage} source={{uri: item.coverImg}}/>
    </View>
    )
    })}
    </Swiper>
    }
    </View>
    )
    }

    //动态加载数据


    getHomeInfo = () => {
    this.props.fetchRequest(this, '', Url.getHomeInfo(), {}, true, true, true, (data, response) => {
    this.setState({
    indexHelpVideoList: data.indexHelpVideoList ?? []
    })
    });

    }


    解决办法是:在没有获取到动态数据时,不初始化swiper。等获取到数据时,才初始化swiper的部分

  • 相关阅读:
    Java 抽象类和抽象方法
    java中的不为空判断
    表单form action的url写法
    对称加密和非对称加密
    spring全注解项目
    java自定义异常
    Spring data jpa学习
    SpringMVC实现简单应用
    MySql与Java的时间类型
    java反射
  • 原文地址:https://www.cnblogs.com/gznuhaoge/p/16167095.html
Copyright © 2020-2023  润新知