我在从 SectionList React-Native 获取标题项的索引时遇到问题。通过按下标题,我试图获取项目的索引,然后将其传递给函数。我尝试了很多事情,但没有运气。有什么建议么。谢谢
我想按下午 3-30 点返回索引 0 我可以按返回我的 Lucian 想法是通过获取标题索引,我可以使用数组从列表中删除一个项目。
<SectionList style = {styles.itemSquare}
renderItem = {({item, index, section}) =>
< Text style={styles.SectionListItemStyle} key = {index}
onPress={this.GetSectionListItem.bind(this, this.state.slotkeys[index])}> {item}
< /Text>}
renderSectionHeader = {({section: {title}, index}) => (
<TouchableHighlight >
<View>
<Text style={styles.SectionHeaderStyle}
onPress={this.GetSectionListItem.bind(this, index)}
> {title}
<Text style={styles.SectionHeaderCancel} > {index} < /Text>
</Text>
</View>
</TouchableHighlight>
)
}
sections = {this.state.slots.map(({ time, chosen_user, name, chosen_syllabud, user_id }) =>
({ title: time, data: [[chosen_user], [chosen_syllabud], [user_id]], index:1 }))}
keyExtractor = {(item, index) => item + index}
/>