Javascript react-native中的嵌套映射
大家好,我是react native的新手,我正在尝试创建详细的下拉列表。下面是我的代码,第一个数组值正在显示,但是数组值没有显示,请帮助我解决这个问题Javascript react-native中的嵌套映射,javascript,react-native,Javascript,React Native,大家好,我是react native的新手,我正在尝试创建详细的下拉列表。下面是我的代码,第一个数组值正在显示,但是数组值没有显示,请帮助我解决这个问题 import React from "react"; import { StatusBar } from "expo-status-bar"; import { Text, View, StyleSheet, TouchableOpacity } from "react-native&q
import React from "react";
import { StatusBar } from "expo-status-bar";
import { Text, View, StyleSheet, TouchableOpacity } from "react-native";
const data = [
{
name: "Jude",
position: "Developer",
experiences: [
{
id: 0,
job: "React UI Developer",
period: "2017-2018",
description:
"I love Creating beautiful Smart UI with React js and styled components",
},
{
id: 1,
job: "React/ Redux UI Developer",
period: "2017-2018",
description:
"I love Creating beautiful Smart UI with React js and styled components",
},
],
},
{
name: "Mikes",
position: "Developer",
experiences: [
{
id: 0,
job: "React UI Developer",
period: "2017-2018",
description:
"I love Creating beautiful Smart UI with React js and styled components",
},
{
id: 1,
job: "React/ Redux UI Developer",
period: "2017-2018",
description:
"I love Creating beautiful Smart UI with React js and styled components",
},
],
},
];
function ExpandList(props) {
return (
<View style={styles.container}>
{data.map(({ name, position, experiences }) => {
return (
<View>
<Text>{name}</Text>
{experiences.map((checkaa) => {
<Text key={checkaa.id}>{checkaa.job}</Text>;
})}
</View>
);
})}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
},
mainList: {},
subCategoryTwo: {
fontSize: 90,
},
});
export default ExpandList;
从“React”导入React;
从“世博会状态栏”导入{StatusBar};
从“react native”导入{文本、视图、样式表、TouchableOpacity};
常数数据=[
{
姓名:“裘德”,
职位:“开发者”,
经验:[
{
id:0,
作业:“反应UI开发人员”,
期间:“2017-2018年”,
说明:
“我喜欢用React js和样式化组件创建漂亮的智能UI”,
},
{
id:1,
作业:“React/Redux UI开发人员”,
期间:“2017-2018年”,
说明:
“我喜欢用React js和样式化组件创建漂亮的智能UI”,
},
],
},
{
名称:“迈克”,
职位:“开发者”,
经验:[
{
id:0,
作业:“反应UI开发人员”,
期间:“2017-2018年”,
说明:
“我喜欢用React js和样式化组件创建漂亮的智能UI”,
},
{
id:1,
作业:“React/Redux UI开发人员”,
期间:“2017-2018年”,
说明:
“我喜欢用React js和样式化组件创建漂亮的智能UI”,
},
],
},
];
功能列表(道具){
返回(
{data.map({name,position,experiences})=>{
返回(
{name}
{experiences.map((checkaa)=>{
{checkaa.job};
})}
);
})}
);
}
const styles=StyleSheet.create({
容器:{
弹性:1,
辩护内容:“中心”,
},
主列表:{},
子类别二:{
尺寸:90,
},
});
导出默认列表;
当我尝试获取experiences数组值时,它没有显示任何内容,我从一天起就陷入了这个问题。您的第二张地图缺少return关键字,因此我对其进行了如下修改:
function ExpandList(props) {
return (
<View style={styles.container}>
{data.map(({ name, position, experiences }) => {
return (
<View>
<Text>{name}</Text>
{experiences.map((checkaa) =>{
return <Text key={checkaa.id}>{checkaa.job}</Text>
})}
</View>
);
})}
</View>
);
}
功能扩展列表(道具){
返回(
{data.map({name,position,experiences})=>{
返回(
{name}
{experiences.map((checkaa)=>{
返回{checkaa.job}
})}
);
})}
);
}