07-列表渲染-map.html

  <div id="root">div>
  <script src="./react.js">script>
  <script src="./react-dom.js">script>
  <script src="./babel.min.js">script>
  <script type="text/babel">


    var arr = ['aaa','nnnn','ccc']

    var h2s=
    //{}是支持map语句得,for循环是不支持得
    //要加key
    const el=(<div>{arr.map(function(curVal,index){
      return <h2 key={index}>{curVal}</h2>
    })}</div>)

    ReactDOM.render(el,document.getElementById('root'))
  
  script>

 

你可能感兴趣的:(07-列表渲染-map.html)