2015-12-02 128 views
2

我有我的路由difined,當我導航到products/new,工作正常,但如果刷新頁面,他products/new不進入,他返回意外的令牌。在react-router路由嵌套url

Route Config。

<Router history={createBrowserHistory()}> 

<Route path="/" component={Layout}> 
    <IndexRoute component={Home} /> 
    <Route path="produtos/novo" component={ProductsNew}/> 
    <Route path="produtos" component={Products} /> 
</Route> 

+0

您需要設置.htaccess或虛擬主機(如果您使用的是Apache)才能將所有請求指向您的應用所在的索引頁面。 – Enijar

+0

這個錯誤只發生在'''products/new''',刷新時其他頁面時,這個工作正常。我的服務器是node + express。 –

+0

您沒有爲您提供的代碼中的'products/new'設置路線。這可能是原因,雖然我需要更多的信息來幫助你... – Enijar

回答

2

我遇到了類似的問題,並最終意識到這不是與之反應路由器,但我自己的道路的問題。這是加載文件相對於/produtos而不是/(與您的示例有關)。

我加<base href="/" />到我index.html<head>和它的工作(: