React modify get the value of state

=== 14 " 
value in the modified state is not directly modify the 
 
    state = { 
        NUM: 10 
    } 

as the this .state.num + = 12 is ; error can not be modified directly 

  by the this .setState ({ 
      NUM: the this .state.num + 12 is 
  })



  15 ==> Get values for the state of 
 PS ==> when you enter a component which can not be used the following way 
 Import} from {StaTest "./components/StaTest" error 
 be StaTest from Import "./ components / StaTest " a component without introducing braces {} 

 Import React, {from} the component " REACT " ; 
 Export default class StaTest extends Component {
    state={
        nun:1
    }
    render(){
        return <div>
            {/* 获取state中的值 */}
            {this.state.nun}
        </div>
    }
  }


import StaTest from "./components/StaTest"
  {/* 使用 */}
  <StaTest></StaTest>

 

Guess you like

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