2017-05-05 27 views
1

我有服務器端渲染應用程序和使用react-router進行路由。我正在使用路由器。運行在作爲方法之前,我正在使用Router.Match。以前有路由變化時,使用router.run來調用,但在router.match中沒有發生相同的行爲。它背後有什麼理由嗎?Router.match沒有被調用每個路由變化

+0

我不能夠完全理解你的problem.can您分享您的代碼> –

回答

0

我已經定義瞭如下定義我的輸入模塊的路由器,它會去佈局組件來尋找路由路徑:

import { Router, Route, IndexRoute, hashHistory } from "react-router"; 
    ReactDOM.render(
    <Router history={hashHistory}> 
    <Route path="/" component={Layout}> 
    //<IndexRoute component={Featured}></IndexRoute> 
    <Route path="archives" name="archives" component={Archives}></Route> 
    <Route path="settings" component={Settings}></Route> 
    <Route path="featured" component={Featured}></Route> 
    </Route> 
    </Router>, 
    document.getElementById('app')); 

佈局組件將綁定在佈局組件

路由器定義爲不同組件的路徑
import { Link } from "react-router"; 
    class Layout extends React.Component(

    render(){ 
    return(

    {this.props.children} 
    <li><MenuItem><Link to="archives">archives</Link></MenuItem></li> 
      <li><MenuItem><Link to="settings">settings</Link></MenuItem></li> 
      <li><MenuItem><Link to="featured">featured</Link></MenuItem></li> 
    ) 

    }   
      ); 

您可以爲您的路線components.its做工精細任何行動,我

相關問題