const nameList = [‘张三‘, ‘李斯‘, ‘许三多‘]
// 方案1: 在 jsx 外面,进行 循环,创建 jsx 元素的数组;
const newList = nameList.map((item, i) =>
{ return <h6 key={i}>{item}</h6> })
……
{newList}
{/* 方案2: 在 jsx 里面,进行循环,创建 jsx 元素的数组; */}
<hr />
{nameList.map((item, i) =>
( <h6 key={i}>{item}</h6> )
)
}
原文:https://www.cnblogs.com/zqblog1314/p/12902262.html