这是我在 Home.js 文件中的完整代码
export default function Home({navigation}) {
const [reviews, setReviews] = useState([
{ title: 'Alfa Romeo 147 1.9JTD', rating: 2020, body: 340000, sg: ['ABS ', 'CD ', 'ESP '], key: '1' },
{ title: 'Gotta Catch Them All (again)', body: 'lorem ipsum', key: '2' },
{ title: 'Not So "Final" Fantasy', body:'lorem ipsum', key: '3' },
{ title: 'Alfaromeo', rating: 3200, body: 'blablabla', first:'loremlo', key: '4' },
{ title: 'Gotta Catch Them All (again)', rating: 4, body: 'lorem ipsum', key: '5' },
{ title: 'Not So "Final" Fantasy', rating: 3, body: 'lorem ipsum', key: '6' },
{ title: 'Alfaromeo', rating: 3200, body: 'sadaa', key: '7' },
{ title: 'Gotta Catch Them All (again)', rating: 4, body: 'lorem ipsum', key: '8' },
]);
return (
<View style={styles.container}>
<FlatList data={reviews} renderItem={({ item }) => (
<TouchableOpacity onPress={() => navigation.navigate('ReviewDetails', item)}>
<View style={styles.content}>
<Image
style={styles.image}
source={{
uri: 'https://www.autoplac-cg.me/storage/1871/conversions/5f9eb91821de1_20FB3486-4A0A-4B4A-B13C-CAE912950E22-thumb.jpg',
}}
/>
<Text style={styles.headertext}>{item.title }</Text>
<Text style={styles.infotext}>{item.rating}god. | {item.body}km <Text style={styles.collapse}>+</Text></Text>
</View>
</TouchableOpacity>
)} />
</View>
); }
所以我想把第一个放在 FlatList 上,检查谁在数组“第一个”中,所以在代码中是第四个。我怎样才能做到这一点?
我希望这是 FlatList 上的第一个
{ title: 'Alfaromeo', rating: 3200, body: 'blablabla', first:'loremlo', key: '4' }
GCT1015
慕姐4208626
江户川乱折腾
相关分类