2016-08-01 180 views
0

我正在使用React-router在我reactjs web應用中進行路由。我想要一組不同的路線來渲染相同的組件。相同組件的不同路由

例如:

http://example.com/abc 
http://example.com/xyz 
http://example.com/pqr 

這些所有的URI將呈現相同的組件

注:我不希望所有的路由來呈現相同的組件。我只想ABC,XYZ和PQR呈現相同的組件

回答

2

只要定義他們,

<Router history={browserHistory}> 
    <Route path="/" component={App}> 
     <Route path="abc" component={YourComponent}/> 
     <Route path="xyz" component={YourComponent}/> 
     <Route path="pqr" component={YourComponent}/> 
     <Route path="*" component={NoMatch}/> 
    </Route> 
    </Router> 
+0

是他們的任何方式來定義這隻能使用單行?像 programmer

+1

我不確定,但是如果path值可以定義爲regexp,那麼可以這樣做。 – Tugrul

+0

你可以有一組路徑並通過它們映射,爲每個路徑返回一個'Route'。 – Geraint

相關問題