javascript - react will report an error when using this.state.
滿天的星座
滿天的星座 2017-05-19 10:29:18
0
4
500

滿天的星座
滿天的星座

reply all(4)
我想大声告诉你

class is the ES6 way of writing.
getIntialState is an ES5 hook function and cannot be used here.

大家讲道理

Define the initial state should be in the constructor:
constructor(props){

super(props);
this.state={
      ss:"xxx"
}

}

迷茫

I feel like there is something wrong with what is written here. This method needs to be bound in the constructor, otherwise this method should not be found if this is lost? this.handlechange

constructor(props) {
    super(props)
    this.handleChange = this.handleChange.bind(this)
}
阿神

If you don’t want to use constructor, define state directly and write directly in class from
`
class... {

state = {

sss

}

// this.state can be obtained
}
`

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template