我有一个ListView组件,用于呈现包含事件列表的日历。数据结构是:
const data = {
'092016':[{id:1,title:'event1'},{id:1,title:'event1'}],
'102016':[{id:1,title:'event1'},{id:1,title:'event1'}],
}
ListView代码:
<ListView
style={{flex:1}}
dataSource={this.state.posts}
pageSize={3}
onEndReachedThreshold={200}
enableEmptySections={true}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps={true}
showsVerticalScrollIndicator={true}
renderRow={(event) => <Text>{event.title}</Text>}
renderSectionHeader={(data,month)=><Text>{month}</Text>}
/>
....dataSource = new ListView.DataSource({
rowHasChanged : (row1, row2) => row1 !== row2,
sectionHeaderHasChanged : (s1, s2) => s1 !== s2});
... on component mount
this.setState({posts:dataSource.cloneWithRowsAndSections(data)});
这可以按预期工作。
现在我希望能够滚动到js中的特定部分。我怎么能做到这一点?
类似
scrollTo('102016') // scroll to section with id='102016'