首页 > 解决方案 > 我的 javascript 中有一个错误,它说 (e) 没有定义

问题描述

在此处输入图像描述

我拥有的代码和图像中的错误

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;

标签: javascriptreactjs

解决方案


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

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

推荐阅读