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 ...
The web pinball game implemented using javeScript...
Table of contents About Kubernetes Basic environm...
Table of contents Overview Virtual Dom principle ...
Table of contents Ref and Reactive Ref Reactive T...
I didn't intend to write this blog, but durin...
Dimensionality reduction of two-dimensional array...
I recently used Docker to upgrade a project. I ha...
1. List query interface effect Before introducing...
Table of contents View network configuration View...
This article shares the specific code for the WeC...
Use Javascript to implement a message board examp...
Table of contents 01 JavaScript (abbreviated as: ...
Table of contents Preface Prototype chain inherit...
vsftpd Overview vsftpd is the abbreviation of &qu...