React那些年, 踩过的一些坑(连载中...)

React 组件构造函数: super(props) vs super()

曾经以为以下两种写法, 没什么大区别, 其实这个坑深着呢

constructor(props) {
    super();
    this.state = this.initData(this.props);

constructor(props) {
    super(props);
    this.state = this.initData(this.props);
  


猜你喜欢

转载自blog.csdn.net/cen_cs/article/details/78083020