2015-12-02 78 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>和它的工作(: