react遍历数组

import React ,{Component} from 'react'
class App extends Component{
  constructor(props){
    super(props)
    this.state = {
      list:["星期一","星期二","星期三"]
    }
  }
  render(){
    return (
      
{ // react里没有指令,只能用map方法遍历数组 this.state.list.map((item,i)=>{ // return 一个标签 标签里要加上key,通常key用数组的下标 return

{item}

}) }
) } } export default App;

 

转载于:https://www.cnblogs.com/luguankun/p/11020592.html

你可能感兴趣的:(react遍历数组)