window.getComputedStyle——ref

componentDidMount() {
    const LeftHeight = window.getComputedStyle(this.leftDom).height;
    console.log(LeftHeight);
    setTimeout(function(){
      const LeftHeight = window.getComputedStyle(this.leftDom).height;
      console.log(LeftHeight);
    }.bind(this),1000)
  }


 return (
      <ContentWarp>
        <div className={ left } ref={ dom => { this.leftDom = dom } }>
          <ContentLeft/>
        </div>
        <div className={ right }>
          <ContentRight/>
        </div>
      </ContentWarp>
    )
  }
原文地址:https://www.cnblogs.com/jkr666666/p/8309877.html