【发布时间】:2020-12-10 05:23:38
【问题描述】:
我想要我的 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
【问题讨论】:
-
请问一个更具体的问题,“这是我的代码,请让它做 X 或 Y”。你的代码是做什么的?你试过什么?您正在用它构建什么样的东西,为回答者提供一些背景信息。
-
我尝试了下面的解决方案,但它给出了错误“滚动索引超出范围”stackoverflow.com/questions/44475202/…
标签: react-native react-native-android react-native-flatlist flatlist