渲染

用map方法:

  1. <div className="doing">
  2. <h1>正在进行</h1>
  3. {this.state.Doing.map(item=>{
  4. return(
  5. <div key={item.id}> //每个map后的父div都需要加上key值
  6. <p>{item}</p> //取数据时格式为 {} vue是两个{{}}
  7. </div>
  8. )
  9. })}
  10. </div>

声明

若初始化不是class结构则清空代码然后在 rcc

  1. class App extends Component {
  2. constructor(props){
  3. super(props);
  4. this.state={
  5. inpValu:'',
  6. Doing:[],
  7. Done:[]
  8. } //读取调用时应写成 this.state.变量名 的格式,与vue有差异
  9. }
  10. }