2016-04-18 132 views
0

组件渲染时react-router是否触发了一个事件?我没有在它的github wiki页面中找到它。
一个就是这样的事件在角UI路由器: $viewContentLoaded - fired once the view is loaded, after the DOM is rendered. The '$scope' of the view emits the event. 反应路由器呈现的事件

回答

0

使用componentDidMount生命周期法,你是路由到组件上。

var YourComponent = React.createClass({ 

    componentDidMount: function() { 
     // Code here 
    }, 

    componentWillUnmount: function() { 
    }, 

    render: function() { 
     return (
     <div> 

     </div> 
    ); 
    } 
}); 

module.exports = YourComponent; 
+0

非常感谢。很棒! – ailionx