为了账号安全,请及时绑定邮箱和手机立即绑定

我的 javascript 中有一个错误,它说 (e) 未定义

我的 javascript 中有一个错误,它说 (e) 未定义

郎朗坤 2023-12-14 14:35:32
我的代码和图像中的错误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>

); };


查看完整回答
反对 回复 2023-12-14
?
慕桂英4014372

TA贡献1871条经验 获得超13个赞

您需要将 e 作为参数添加到地图中。然后,数组中的值将显示为列表元素。

  <ol>        
      {joiningCriteria.map((e)=> (<li>{e}</li>))}
  </ol>


查看完整回答
反对 回复 2023-12-14
?
哔哔one

TA贡献1854条经验 获得超8个赞

请将(e)添加到地图中,例如

map(()=>

map((e)=>

会起作用的

谢谢


查看完整回答
反对 回复 2023-12-14
  • 3 回答
  • 0 关注
  • 113 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信