【问题标题】:react-native-snap-carousel tutorial on how to use itreact-native-snap-carousel 教程如何使用它
【发布时间】:2020-02-05 05:53:54
【问题描述】:

我试图找到任何关于实现 react-native-snap-carousel 示例的教程,但我找不到任何教程。如果你们中有人看过这方面的任何教程,请建议一个链接。 我已经阅读了它的创建者提供的文档和示例,但是对我来说它们看起来很复杂。

【问题讨论】:

    标签: react-native components carousel swipe react-native-snap-carousel


    【解决方案1】:

    您必须提供数据,它会自动映射并分配功能组件以呈现项目,它将返回带有索引和项目的 json 格式,您可以在下面的示例中看到

    const container = ({edges,_loadmore,navigation}) =>{
     const _renderItem = ({ item, index }) => {
     return (
        <View>
          <Render_component  />
        </View>
       );
    };
        return (
         <Carousel
        onSnapToItem={slideIndex => {
          setcurrentSlider(slideIndex);
          _loadMore();
        }}
        onBeforeSnapToItem={slideIndex => {
          setBeforeSlider(slideIndex);
        }}
        inactiveSlideOpacity={1}
        inactiveSlideScale={1}
        enableSnap
        ref={carRef}
        data={edges}
        renderItem={_renderItem}
        sliderHeight={screenHeight}
        itemHeight={screenHeight}
        vertical={true}
    
        />
        )
    }
    

    【讨论】:

      猜你喜欢
      • 2019-01-27
      • 2020-03-18
      • 2020-09-03
      • 2020-10-20
      • 2018-03-06
      • 2020-01-07
      • 1970-01-01
      • 2018-03-31
      • 2020-03-22
      相关资源
      最近更新 更多