2016-12-02 3 views
1

私はreact-routerに慣れています。私たちは何らかの変化に下記の反応-ルータを新しいルーティングページを変更するためのReact-routing設定の問題

module.exports = (
    <Router history={HashHistory}> 
    <Route path="/" component={Frame}> 
     <IndexRoute component={Page1} /> 
     <Route path="all" component={Page2} /> 
     <Route path="admin" component={Page3} /> 
     <Route path="proxy" component={Page4} /> 
     </Route> 
    </Router> 
); 

を使用している現在のアプリで

は、今私は、ホームページとして別のページを作りたいだけでなく、現在の機能をunimpactする最小限の変更を行いたいです。下記のルータの設定を使用したが、問題を解決するために、これを探求する

<Router history={HashHistory}> 
    <Route path="/" component={Home}> 
     <Route path="achieve" component={Frame}> 
      <Route path ="achieve" component={Page1}> 
      <Route path="all" component={Page2} /> 
      <Route path="admin" component={Page3} /> 
      <Route path="proxy" component={Page4} /> 
     </Route>    
    </Route> 
    </Route> 
    </Router> 

どれポインタを動作していませんか?

ありがとうございます。

答えて

0

ホームページとして各ページを作成したい場合は、ネストされたルートを使用しないで、それぞれ別のルートを作成します。 これを試してください:あなたはその内のいくつかのコンポーネントを使用したいというルートで営巣

<Router history={HashHistory}> 
    <Route path="/" component={Home}/> 
    <Route path="/achieve" component={Frame}/> 
    <Route path ="/achieve" component={Page1}/> 
    <Route path="/all" component={Page2} /> 
    <Route path="/admin" component={Page3} /> 
    <Route path="/proxy" component={Page4} /> 
</Router> 

使用。

<Router history={HashHistory}> 
    <Route path="/" component={Home}/> 
    <Route path="/achieve" component={Frame}/> 
    <Route path ="/achieve" component={Page1}/> 
    <Route path="/all" component={Page2} /> 
    <Route path="/admin" component={Page3} > 
     <IndexRoute component={comp1}/>      
     <Route path="/xyz" component={comp2}/> 
    </Route> 
    <Route path="/proxy" component={Page4} /> 
</Router> 

は、より良い説明のためにこれらのリンクに従ってください:あなたは、その後の管理ページ内のいくつかのコンポーネントを使用したいとしましょう

https://css-tricks.com/learning-react-router/

https://medium.com/@dabit3/beginner-s-guide-to-react-router-53094349669#.sjzpetwbb

任意の助けが必要な場合はコメントしてください。

+1

ありがとう@ mayank-shukla ...それは私のために働いた。どうもありがとう。 –

関連する問題