componentWillMount和componentDidMount的区别

1、componentWillMount  将要装载,在render之前调用;

      componentDidMount,(装载完成),在render之后调用

2、componentWillMount  每一个组件render之前立即调用;

      componentDidMount  render之后并不会立即调用,而是所有的子组件都render完之后才可以调用

3、componentWillMount  可以在服务端被调用,也可以在浏览器端被调用;

      componentDidMount  只能在浏览器端被调用,在服务器端使用react的时候不会被调用

 

posted @ 2018-03-06 18:35  星空0909  阅读(26422)  评论(0编辑  收藏  举报