0

我想要我的 Flatlist 自动滚动并在水平方向循环,请帮助我提前致谢

          <FlatList
             style={{marginEnd:5}}
             timer={2000}
             //  width={deviceWidth}
              loop={true}
             // keyExtractor={this._keyExtractor.bind(this)}
              horizontal={true}
              onScrollToIndexFailed={info => {
                 const wait = new Promise(resolve => setTimeout(resolve, 500));
                 wait.then(() => {
                    flatListFeaturedMobiles.current?.scrollToIndex({ index: info.index, animated: true });
                 });
               }}
             //  onScrollToIndexFailed={()=>{}}
              flatListRef={React.createRef()}
              ref={this.flatListFeaturedMobiles}
              autoscroll={true}
              
            showsHorizontalScrollIndicator={false}
        data={this.state.featuredMobiles}
        horizontal
4

1 回答 1

0

您可以使用 Animated 滚动列表,如检查它如何使列表(FlatList)自动滚动

你也可以使用react-native-autoscroll-flatlist#readme

有关更多详细信息,您可以在此处阅读want-to-autoscroll-flatlist-in-react-native

于 2020-12-10T05:42:12.880 回答