鍍金池/ 問答/HTML/ reactrouter問題

reactrouter問題

 <Router history={history}>
  <HomeLayout>
    <Route path="/" exact component={IndexPage} />
    <Route path="/labelingSystem/:id" component={LabelingSystem} />
  </HomeLayout>
</Router>
    Homelayout 為 公共導(dǎo)航 現(xiàn)在調(diào)用接口 返回數(shù)據(jù) 之后

const {children} = this.props;
    獲取 children
 <Layout>
   {children}
 </Layout>
     根據(jù)點擊不同的Link 跳轉(zhuǎn)渲染不同的頁面
export default connect(({ menuData }) => ({
  menuData
}))(HomeLayout);
    router 地址欄 地址變了 頁面沒有跳轉(zhuǎn)重新渲染    

求解問什么,頁面無報錯

回答
編輯回答
絯孑氣

export default withrouter(connect(({ menuData }) => ({
menuData
}))(HomeLayout));
創(chuàng)建時候 外層包 一個 withrouter
可以解決

2017年7月28日 03:18
編輯回答
葬憶

Route外加一個Switch試試

2018年4月6日 06:18