同事追问下,发现知识漏洞之为什么要加super(this)
2018-04-19 本文已影响14人
春木橙云
一句话解释:不加的话在constructor()
函数中用不了this
,进一步说也就用不了state
状态机
class a extends Component {
constructor(props){
super(props);
this.state = {
}
}
}
THE END!
一句话解释:不加的话在constructor()
函数中用不了this
,进一步说也就用不了state
状态机
class a extends Component {
constructor(props){
super(props);
this.state = {
}
}
}
THE END!