我有一個帶有不同卡片的屏幕(有文章信息)我試圖在按下方便的類別時按類別過濾文章我希望選擇該類別并顯示屬于該類別的文章,另一方面當沒有選擇任何類別時,將所有類別中的所有文章都交給顯示(如果您看下面的圖片,這將更有意義)用于顯示不同類別圖片的代碼:import TouchableScale from "react-native-touchable-scale";import { category } from "../api/data";import colors from "../config/colors";function HotTopics({ navigation }) { //const { width, height } = Dimensions.get("window"); return ( <View style={styles.Container}> <View> <Text style={styles.CategoryText}>Hot Topics</Text> </View> <FlatList horizontal showsHorizontalScrollIndicator={false} style={{ paddingHorizontal: 15 }} data={category} keyExtractor={(item) => item.id} renderItem={({ item }) => { return ( <View> <View> <TouchableScale activeScale={0.9} tension={50} friction={7} useNativeDriver onPress={() => navigation.navigate({ id: item.id })} > {/* to show the horizental news list*/} <Image source={{ uri: item.image }} style={{ width: 100, height: 120, borderRadius: 16, marginRight: 10, }} /> {/* to show the news titles inside the pictures*/} <SharedElement id={`item.${item.id}.text`} style={{ width: 100, position: "absolute", bottom: 95, //left: 10, paddingHorizontal: 5, justifyContent: "center", alignItems: "center", }}
在反應本機中按下字段時過濾項目
泛舟湖上清波郎朗
2022-10-13 15:39:35