React circulating rendered similar in v-for Vue

17 == "loop array similar V- for 

Import React, {from} the Component " REACT " ; 

Export default class CharShop the extends the Component {
     // State initialization which generally written in the constructor 
    constructor (The props) { 
        Super (The props); 
        the this . State = { 
            Goods: [ 
             {ID: . 1, text: "web111" }, 
             {ID: 2, text: "web222" }, 
             {ID: . 3, text: "web333" } 
            ] 
        } 
    } 


     the render () { 
         return (
              <div> 
                {/* 条年渲染  类v-for */}
                {this.state.goods.map(item=>
                  return  <li key={item.id}>{item.text}</li>
                )}
             </div>
         )
     }
}

 

Guess you like

Origin www.cnblogs.com/IwishIcould/p/11966816.html