React中jsx对于二维数组的遍历可以通过map方法,记得需要为每一个元素传入一个key值,不然会报错,提示the key is unique;
const data = [
[
{ title: '阿甘0', description: '讲述阿甘的奋斗' },
{ title: '阿甘1', description: '讲述阿甘的奋斗' },
{ title: '阿甘2', description: '讲述阿甘的奋斗' },
{ title: '阿甘3', description: '讲述阿甘的奋斗' },
],
[
{ title: '阿甘4', description: '讲述阿甘的奋斗' },
{ title: '阿甘5', description: '讲述阿甘的奋斗' },
{ title: '阿甘6', description: '讲述阿甘的奋斗' },
{ title: '阿甘7', description: '讲述阿甘的奋斗' },
]
];
//通过唯一的title可以确定唯一的key;
{
data.map( items => (
items.map( item => (
<div key ={item.title}>{item.description}</div>
))
))
}