2015-10-14 75 views
3

我正在嘗試在我的反應和redux應用程序中進行路由,但仍然不是運氣。react router + restorex警告:位置「xyz」與任何路徑不匹配

index.js:

import React from 'react'; 
import { render } from 'react-dom'; 
import { Router, Route, IndexRoute } from 'react-router'; 
import { Provider } from 'react-redux'; 
import { createHistory } from 'history'; 

import DashboardApp from './containers/App'; 
import QuizApp from './containers/QuizApp'; 
import Page from './containers/Page'; 
import store from './store'; 

const routes = <Router history={createHistory()}> 
    <Route path="/" component={Page}> 
     <IndexRoute component={DashboardApp} /> 
     <Route path="quiz" component={QuizApp} /> 
    </Route> 
</Router>; 

render(
    <Provider store={store}> 
     {routes} 
    </Provider>, document.getElementById('app')); 

默認視圖被適當地生成的。在DashboardApp我有這樣的代碼:

<Link to='quiz'>Quiz</Link> 

如果我點擊它,我得到錯誤控制檯:

Warning: Location "quiz" did not match any routes 

我將不勝感激任何提示怎麼解決呢

回答

1

你需要使用絕對路徑而不是名稱。

<Link to='/quiz'>Quiz</Link>

見鏈接組件文檔中描述here

+0

當然:d非常感謝! – Kania

相關問題