2017-04-05 7 views
0

Route about-us funktioniert nicht. Funktioniert nur, wenn ich der Route einen Präfix hinzufüge Country. Wie kann ich es reparieren. Vielen Dank.Route statisch nicht funktioniert

<Route path="/" component={App}> 
    <IndexRoute components={Home}/> 
    <Route path=":country" components={Country}/> 
    <Route path=":country/:city" components={City}/> 
    <Route path="*" components={NotMatch}/> 
    <Route path="about-us" components={AboutUs}/> 
</Route> 

Antwort

0

Dank Mayank Shukla. Du hast mir die richtige Deriktion gegeben.

<Route path="/" component={App}> 
    <IndexRoute components={Home}/> 
    <Route path="/about-us" components={AboutUs}/> 
    <Route path=":country" components={Country}/> 
    <Route path=":country/:city" components={City}/> 
    <Route path="*" components={NotMatch}/> 
</Route> 

Dies funktioniert.

1

tauschen diese 2 Zeilen,

Statt:

<Route path="*" components={NotMatch}/> 
<Route path="about-us" components={AboutUs}/> 

verwenden:

<Route path="about-us" components={AboutUs}/> 
<Route path="*" components={NotMatch}/> 

Und die : von Route country und country/:city entfernen.

So:

<Route path="/" component={App}> 
    <IndexRoute components={Home}/> 
    <Route path="country" components={Country}/> 
    <Route path="country/:city" components={City}/> 
    <Route path="about-us" components={AboutUs}/> 
    <Route path="*" components={NotMatch}/> 
</Route> 
+0

Überprüfen Sie die aktualisierte Antwort :) –