简体   繁体   English

我如何以数组格式表示这些数据

[英]How can i represent this data in array format

Good day guys!伙计们,美好的一天! I have a list of data which i want to hard code into a react native app but i dont know how to represent the data in an array.我有一个数据列表,我想将这些数据硬编码到 React Native 应用程序中,但我不知道如何在数组中表示数据。 I hope you can help me out.我希望你能帮助我。

So there is a title and subtitles in the array.所以数组中有标题和副标题。 Here is an example这是一个例子

const [people, setPeople] = useState([{
    title: "Evidence Act", 
    id: "1",
    subtitle:[{
        part: "Introduction cc", 
        meaning: "how are you don"
    }, {
        part: "Introduction bb", 
        meaning: "how are you don"
    }]
}])

The above code does no work well for me.上面的代码对我来说不起作用。 The flatlist does not map through the "part".平面列表不映射通过“部分”。 It only displays the first part.它只显示第一部分。

Please is is there a better way to represent this type of data in an array.请问有没有更好的方法在数组中表示这种类型的数据。 I will really appreciate your help...我将非常感谢您的帮助...

 const [people, setPeople] = useState([ {Law: "Evidence Act", id: "1", part:[ {name: "Introduction cc", meaning: "how are you don"}, {name: "Introduction bb", meaning: "how are you don"} ] }, ]) return ( <FlatList numColumns={1} keyExtractor={(item) => item.id} data={people} renderItem={({ item }) => ( <List > <ListItem onPress={() => navigation.navigate('NigLawParts', item)}> <Text style={{ fontSize: 20, }}>{item.Law}</Text> </ListItem> </List> )} keyExtractor={(item, index) => index.toString()} />

This is what i have now.这就是我现在所拥有的。 I just want to display all the item.part[0]name and item.part[0]meaning in different pages我只想在不同的页面中显示所有 item.part[0]name 和 item.part[0] 含义

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM