我创建了 12 个元素的部分列表。这是我的代码,
render() {
return (
<View style={styles.container}>
<SectionList
renderItem={({item}) =><Text onPress={() => alert(item)} style={styles.item}>{item}</Text> }
sections={[
{title: 'A', data: ['Audi']},
{title: 'B', data: ['BMW']},
{title: 'H', data: ['Honda', 'Hyundai']},
{title: 'J', data: ['Jaguar']},
{title: 'K', data: ['Kia']},
{title: 'M', data: ['Mazda','Mercedes-Benz', 'Mitsubishi']},
{title: 'N', data: ['Nissan']},
{title: 'T', data: ['Toyota']},
{title: 'V', data: ['Volkswagen']},
]}
renderSectionHeader={({section}) => <Text style={styles.sectionHeader}>{section.title}</Text>}
keyExtractor={(item, index) => index}
/>
</View>
);
}
现在我需要知道是否按此列表中的任何项目,然后导航到每个屏幕。这意味着如果我触摸奥迪然后导航到奥迪页面。这个怎么做?或者知道如何在没有节列表但看起来像的情况下做到这一点?