React class中的super(props)

一、起因:

  1.super引用父类构造函数,在调用super之前,不能用this。

  2.在使用super()之后,构造函数结束之前,this.props的值为undefined。

二、作用:使用super(props),调用父类构造函数,并初始化this.props。

 

posted @ 2021-10-30 19:58  starlog  阅读(298)  评论(0编辑  收藏  举报