First, let's simulate the data coming from the background. Here, in order to make the code clear, the data is simply simulated. import bg3 from './image/bg3.png' constructor(props){ super(props) this.state = { ///Here list:[ { id:1,img:bg3}, { id:2,img:bg3}, { id:3,img:bg3}, { id:4,img:bg3}, { id:5,img:bg3}, ], /// } } Then use the map method to loop out { this.state.list.map((item,key) => { return ( <div className="winfor" onClick={() => console.log(item.id)}> <img src={item.img} className="winforimg" /> </div> ) }) } Added: React loop listimport React, {Component} from 'react'; import logo from './logo.svg'; import './App.css'; import {Person,Twoway} from './Person/Person' class App extends Component { state={ persons:[{name:'Little Fairy',age:'18'},{name:'Xiaoyu',age:'18'},{name:'Jiaxuan',age:'18'}], } render(){ const listItems = this.state.persons.map((item,index) => <Person name={item.name} age={item.age} key={index} /> ); return( <div className="App"> {listItems} </div> ) } } export default App; This is the end of this article about the implementation of react loop data. For more relevant react loop data content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: How to use commands in Mysql to achieve hierarchical search help detailed explanation
>>: Detailed installation and configuration of hadoop2.7.2 under ubuntu15.10
This article example shares the specific code of ...
This article shares the specific code of js to im...
Table of contents environment: 1. Docker enables ...
I. Introduction Docker technology is very popular...
1. Download the download link Click download. You...
Table of contents What is Flattening recursion to...
1. Basic Concepts //Any container can be specifie...
The previous articles introduced the replacement ...
Table of contents 1. Preparation before developme...
Table of contents 0. The kernel tree that comes w...
Table of contents 1. Global Guard 1.1 Global fron...
I recently stumbled upon the Audiovisual Linux Pr...
1. Demand The local test domain name is the same ...
Table of contents Hidden Problems Solution to ada...
Table of contents Manual backup Timer backup Manu...