我尝试了Flatlist,SectionList,Animated.Flatlist和Animated.SectionList, 这是一个简单的示例,如何检查scrollToLocation:
<SectionList
onLayout={this.onLayout.bind(this)}
ref={ref => {
this.sectionList = ref
console.log('ref.scrollToLocation: ' + CircularJSON.stringify(ref.scrollToLocation))
} }
ListHeaderComponent={() => <View style={{height:300, width:300, backgroundColor:'green'}}></View>}
sections = {[{key: 1, data: [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}]}
renderItem = {() => <View style={{width:300, height: 100, marginBottom:20, backgroundColor:'red'}}></View>}
/>
预期会看到scrollToLocation方法,但显示 undefined
。
如果您有任何想法,请帮助我。谢谢!
Env:
"react": "16.6.3",
"react-native": "0.57.8",
Simulator: Xcode 10 iPhone X
答案 0 :(得分:0)
尝试以这种方式实施。
this.SectionList.scrollToLocation({sectionIndex,itemIndex})
render(){
return(<SectionList
ref={ref=>{this.SectionList = ref}}
otherProps
/>)
}