我的代码和图像中的错误import React from 'react';const Main = () => { const joiningCriteria = [ 'People between the ages of 18 and 35 years.', 'A demonstrated passion for coding and technology.', 'The time and capacity to commit to a full coding bootcamp. Classes are three times per week in person at one of our learning hubs.', 'An intermediate level of English comprehension.', 'The aptitude to succeed in the selection process.', ]; return ( <section class="bootcamp"> <ol> {joiningCriteria.map(() => ( <li>{e}</li> /*the error is here it say the (e) is not defined*/ ))} </ol> </section> );};export default Main;
3 回答
largeQ
TA贡献2039条经验 获得超7个赞
要使地图正常工作,您必须传递一个允许选择每个元素的变量。尝试这个
const joiningCriteria = [
'People between the ages of 18 and 35 years.',
'A demonstrated passion for coding and technology.',
'The time and capacity to commit to a full coding bootcamp. Classes are three times per week in person at one of our learning hubs.',
'An intermediate level of English comprehension.',
'The aptitude to succeed in the selection process.',
];
return (
<ol>
{joiningCriteria.map((e,index)=> {return <li key={index}>{e}</li>} /*the error is here it say the (e) is not defined*/
)}
</ol>
</section>
); };
慕桂英4014372
TA贡献1871条经验 获得超13个赞
您需要将 e 作为参数添加到地图中。然后,数组中的值将显示为列表元素。
<ol> {joiningCriteria.map((e)=> (<li>{e}</li>))} </ol>
添加回答
举报
0/150
提交
取消