首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用平面列表集成react-native-swiper

如何使用平面列表集成react-native-swiper
EN

Stack Overflow用户
提问于 2019-01-22 21:25:38
回答 1查看 3K关注 0票数 2

我正在尝试集成react-native-swiper,它可以在里面加载视频。我正在寻找一种将其与平面列表集成的方法。但是数据加载不正确,有没有其他方法可以使用平面列表(使用array.map())加载数据

代码语言:javascript
复制
export default class HomeTab extends Component {
    render() {
     return (
       <FlatList
          data={Data}
          keyExtractor={(item, index) => item.id}
          renderItem={({item}) =>

            <Swiper style={styles.wrapper} 
                showsButtons={false}
                horizontal={true}
                loop={false}
                index={item.id}
                activeDot={
                  <View></View>
                }
                dot={
                  <View></View>
                }
                >
                  <View style={styles.slide1}>
                            <Video 
                                source={{uri: item.media}}   // Can be a URL or a local file.
                                ref={(ref) => {
                                  this.player = ref
                                }}        
                                resizeMode={'contain'}
                                style={styles.backgroundVideo} 
                        />

                      </View>
            </Swiper>

            }
          />
    )
  }
}

使用npm包: react-native-swiper https://www.npmjs.com/package/react-native-swiper

EN

回答 1

Stack Overflow用户

发布于 2019-05-28 22:55:25

尝试使用这个库,因为在下面的示例中react-native-swiper-flatlist它有扁平列表:

代码语言:javascript
复制
  <SwiperFlatList
        autoplay
        autoplayDelay={3}
        index={3}
        autoplayLoop
        data={items}
        renderItem={({item}) => // Standard Image
                            <View style={[styles.child, { backgroundColor: '#000' }]}>
                                <Image
                                    source={{uri:item.key}}
                                    style={styles.checkoutSliderImage}
                                />
                                <Text>{item.key}</Text>
                            </View>
                        }
        showPagination
      />
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54309323

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档