美文网首页
同事追问下,发现知识漏洞之为什么要加super(this)

同事追问下,发现知识漏洞之为什么要加super(this)

作者: 春木橙云 | 来源:发表于2018-04-19 11:02 被阅读14次

    一句话解释:不加的话在constructor()函数中用不了this,进一步说也就用不了state状态机

    class a extends Component {
      constructor(props){
    
        super(props);
          this.state = {
    
          }
        }
    }
    
    

    THE END!

    相关文章

      网友评论

          本文标题:同事追问下,发现知识漏洞之为什么要加super(this)

          本文链接:https://www.haomeiwen.com/subject/cqzikftx.html