2.1map >[success] 咋一看跟forEach用法一样,然而 F12打开调试发现有条警告,是的,map函数遍历项时可以有返回值的,(像:arr.map(ele=> { return ele }))不添加也没关系,但添上更好 import React,{ Component } from 'react' class TestArray extends Component{ render(){ const arr = [1,2,3,4,5]; var newArr = []; arr.map((ele,index)=> { var temp =
  • {ele}
  • newArr.push(temp) return